function createComponent($name) { switch ($name) { case 'loginForm': $form = new NAppForm(); $form->getElementPrototype()->addClass('ajax'); $form->addText('login', _('Prihlasovacie meno'))->addRule(NFORM::FILLED, _('Prihlasovacie meno musí byť vyplnené')); $form->addPassword('password', 'Heslo')->addRule(NFORM::FILLED, _('Heslo musí byť vyplnené.')); $form->addSubmit('btn_submit', _('Prihlásiť sa')); $form->addHidden('backlink'); $form->onSuccess[] = array($this, 'onSubmitAuthenticate'); $this->addComponent($form, $name); break; case 'cartLoginForm': $form = new NAppForm(); $form->getElementPrototype()->addClass('ajax'); $form->addText('login', _('Prihlasovacie meno'))->addRule(NFORM::FILLED, _('Prihlasovacie meno musí byť vyplnené')); $form->addPassword('password', 'Heslo')->addRule(NFORM::FILLED, _('Heslo musí byť vyplnené.')); $form->addSubmit('btn_submit', _('Prihlásiť sa')); $form->addHidden('backlink'); $form->onSuccess[] = array($this, 'onSubmitAuthenticate'); // dump($form);exit; $this->addComponent($form, $name); break; default: return parent::__construct(); break; } }
/** * Create contact form controler * @return NAppForm */ public function createComponentPopForm() { $id = (int) $this->getParam('id'); $form = new NAppForm(); $form->addTextArea('body', 'Zpráva:', 40, 10)->addRule(NForm::FILLED, 'Vyplňte prosím obsah zprávy.'); $form->addText('contact', 'Kontakt na Vás (e-mail nebo telefon):')->addRule(NForm::FILLED, 'Nezapomeňte prosím uvést na sebe kontakt.'); $form->addImage('popsend', NEnvironment::getVariable('baseUri') . 'layout/img/form-send.jpg', 'Odeslat'); $form->addHidden('id', $id); $form->getElementPrototype()->class('ajax'); $form['body']->getControlPrototype()->class('s100 h140px'); $form['contact']->getControlPrototype()->class('s100'); $form->onSubmit[] = callback($this, 'popFormSubmited'); return $form; }
function createComponent($name) { switch ($name) { case 'baseForm': $form = new NAppForm(); $form->getElementPrototype()->addClass('ajax'); $form->addText('login', _('Prihlasovacie meno'))->addRule(NFORM::FILLED, _('Prihlasovacie meno musí byť vyplnené')); /* * todo nejaky problem pri odhlaseny */ // $form->addProtection(_('Bohužial Váš formulár expiroval. Prosím odošlite formulár znovu.') ); $renderer = $form->getRenderer(); $renderer->wrappers['controls']['container'] = NULL; $renderer->wrappers['pair']['container'] = 'div'; $renderer->wrappers['label']['container'] = NULL; $renderer->wrappers['control']['container'] = NULL; $form->addPassword('password', 'Heslo')->addRule(NFORM::FILLED, _('Heslo musí byť vyplnené.')); $form->addSubmit('btn_submit', _('Prihlásiť')); $form->addHidden('backlink'); return $form; break; case 'loginForm': $form = $this->createComponent('baseForm'); $form->onSuccess[] = array($this, 'onSubmitAuthenticate'); $this->addComponent($form, $name); break; case 'classicLoginForm': $form = $this->createComponent('baseForm'); $form->onSuccess[] = array($this, 'onSubmitAuthenticate'); $this->addComponent($form, $name); break; default: return parent::createComponent($name); break; } }