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; }
/** * factory for form for setting complete user info * * @return MyAppForm */ protected function createComponentUserInfoForm() { $form = new MyAppForm(); $form->getElementPrototype()->class('ajax'); if (!is_null($this->getTranslator())) { $form->setTranslator($this->getTranslator()); } $form->getRenderer()->wrappers['label']['requiredsuffix'] = " *"; $form->addText('firstname', 'First Name')->addRule(Form::FILLED)->addRule(Form::MIN_LENGTH, NULL, 2)->addRule(Form::MAX_LENGTH, NULL, 70); $form->addText('lastname', 'Last Name')->addRule(Form::FILLED)->addRule(Form::MIN_LENGTH, NULL, 2)->addRule(Form::MAX_LENGTH, NULL, 70); $form->addText('username', 'User Name')->addRule(Form::FILLED)->addRule(Form::MIN_LENGTH, NULL, 3)->addRule(Form::MAX_LENGTH, NULL, 30); $form->addText('email', 'E-Mail')->setEmptyValue('@')->addRule(Form::FILLED)->addRule(Form::EMAIL)->addRule(Form::MAX_LENGTH, NULL, 60); $form->addPassword('password', 'Password')->setOption('description', 'Fill in only if you want to change current password')->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, NULL, 6); $form['password']->getControlPrototype()->autocomplete('off'); $form->addPassword('password2', 'Confirm Password')->setOption('description', 'Fill in only if you want to change current password')->addConditionOn($form['password'], Form::FILLED)->addRule(Form::FILLED, 'Confirm your password!')->addRule(Form::EQUAL, 'No match for passwords!', $form['password']); $form->addPassword("currentPassword", "Current Password", 60)->setOption('description', 'Fill in only if you want to change current password')->addConditionOn($form['password'], Form::FILLED)->addRule(Form::FILLED); $form->addSubmit('save', 'Save')->getControlPrototype()->class[] = 'ok-button'; $form->onSubmit[] = callback($this, 'save'); return $form; }