Example #1
0
 protected function createComponentLoginForm($name)
 {
     $form = new MyAppForm($this, $name);
     if ($this->useAjax) {
         $form->enableAjax();
     }
     if (!$this->useAutocomplete) {
         $form->getElementPrototype()->autocomplete('off');
     }
     if (isset($this->getPresenter()->translator)) {
         $form->setTranslator($this->getPresenter()->translator);
     }
     if ($this->errorsAsFlashMessages) {
         $form->setErrorsAsFlashMessages();
     }
     $form->addClass('loginFrm');
     $form->addText('username', $this->labels['username'])->addRule(Form::FILLED, 'Enter your username!');
     $form->addPassword('password', $this->labels['password'])->addRule(Form::FILLED, 'Enter your password!');
     if ($this->useRemember) {
         $form->addCheckbox('remember', $this->labels['remember']);
     }
     //	if using labelOver we need to add class to ensure label is visible with javascript disabled
     if ($this->useLabelOver) {
         $form['password']->getLabelPrototype()->class('onlyJS');
         $form['username']->getLabelPrototype()->class('onlyJS');
     }
     $form->addHidden('key');
     $form->addHidden('anchor');
     $form->addSubmit('ok', $this->labels['submit'])->getControlPrototype()->class[] = 'ok-button';
     if ($this->useProtection) {
         $form->addProtection('Form validity time expired. Please send the form again.');
     }
     $form->onSubmit[] = callback($this, 'loginFormSubmitted');
     return $form;
 }