public function init() { /* Form Elements & Other Definitions Here ... */ $element = new Zend_Form_Element_Text('login'); $element->setLabel('Login')->setRequired(); $validator = new Zend_Validate_NotEmpty(); $validator->setMessage('Le login est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY); $element->addValidator($validator); $validator = new Zend_Validate_StringLength(); $validator->setMax(40); $element->addValidator($validator); $filter = new Zend_Filter_StringTrim(); $element->addFilter($filter); $this->addElement($element); $element = new Zend_Form_Element_Password('password'); $element->setLabel('Mot de passe')->setRequired(); $validator = new Zend_Validate_NotEmpty(); $validator->setMessage('Le mot de passe est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY); $element->addValidator($validator); $validator = new Zend_Validate_StringLength(); $validator->setMax(40); $element->addValidator($validator); $filter = new Zend_Filter_StringTrim(); $element->addFilter($filter); $this->addElement($element); }
/** * Creates the form to log in. * @see Zend_Form::init() */ public function init() { $this->setMethod('post'); $this->setAction("/auth/login/"); $usernameElement = new Zend_Form_Element_Text('username'); $usernameElement->setLabel("Benutzername"); $usernameElement->addValidator('regex', false, array('/^[a-z0-9]/i')); $usernameElement->addValidator('stringLength', false, array(2, 64)); $usernameElement->setAttrib('maxLength', 64); $usernameElement->setRequired(true); $passwordElement = new Zend_Form_Element_Password('password'); $passwordElement->setLabel("Passwort"); $passwordElement->addValidator('regex', false, array('/^[a-z0-9]/i')); $passwordElement->addValidator('stringLength', false, array(8, 32)); $passwordElement->setAttrib('maxLength', 32); $passwordElement->setRequired(true); $submitElement = new Zend_Form_Element_Submit('submit'); $submitElement->setLabel('Anmelden'); $submitElement->setIgnore(true); $submitElement->setAttrib('class', 'submit'); $submitElement->removeDecorator('DtDdWrapper'); $this->addElements(array($usernameElement, $passwordElement)); $this->addDisplayGroup(array('username', 'password'), 'credentialGroup', array('legend' => 'Zugangsdaten')); $this->addElements(array($submitElement)); }
function editUserPassword() { $this->setMethod('post'); $this->addAttribs(array('id' => 'formAccountEditPassword', 'class' => '')); $filters = array(new Zend_Filter_StringTrim(), new Zend_Filter_StripTags()); $control = new Zend_Form_Element_Hidden('control'); $control->setValue('editPassword'); $this->addElement($control); $oldPassword = new Zend_Form_Element_Password('oldPassword'); $oldPassword->setLabel('Old password'); $oldPassword->addValidator(new Zend_Validate_StringLength(6, 32)); $oldPassword->setAttribs(array('class' => 'text validate[required,minSize[6],maxSize[32]] rightAdd', 'minlenght' => '6', 'maxlenght' => '32', 'autocomplete' => 'off', 'oncontextmenu' => 'return false', 'data-prompt-position' => 'topLeft:0')); $oldPassword->setRequired(true); $this->addElement($oldPassword); $password = new Zend_Form_Element_Password('password'); $password->setLabel(Zend_Registry::get('translate')->_('admin_administrators_new_password')); $password->addValidator(new Zend_Validate_StringLength(6, 32)); $password->setAttribs(array('class' => 'text validate[required] rightAdd', 'maxlenght' => '32', 'autocomplete' => 'off', 'oncontextmenu' => 'return false', 'ondrop' => 'return false', 'onpaste' => 'return false')); $password->setRequired(true); $this->addElement($password); $retypePassword = new Zend_Form_Element_Password('retypePassword'); $retypePassword->setLabel(Zend_Registry::get('translate')->_('admin_administrators_retype_new_password')); $retypePassword->addValidator(new Zend_Validate_Identical('password')); $retypePassword->addValidator(new Zend_Validate_StringLength(6, 32)); $retypePassword->setAttribs(array('class' => 'text validate[required] rightAdd', 'maxlenght' => '32', 'autocomplete' => 'off', 'oncontextmenu' => 'return false', 'ondrop' => 'return false', 'onpaste' => 'return false')); $retypePassword->setRequired(true); $retypePassword->setIgnore(true); $this->addElement($retypePassword); $submit = new Zend_Form_Element_Submit('savePassword'); $submit->setValue(Zend_Registry::get('translate')->_('apply_password')); $submit->setAttribs(array('class' => 'submit tsSubmitLogin fL')); $submit->setIgnore(true); $this->addElement($submit); $this->setElementFilters($filters); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->setAttribs(array('class' => 'form-horizontal')); $decoratorField = new My_Decorator_FieldLogin(); $elements = array(); // Add oldpass field $input = new Zend_Form_Element_Password('oldpassword', array('required' => true, 'label' => 'Old Password:'******'id' => 'oldpassword', 'placeholder' => 'Old pass..', 'class' => 'form-control')); $input->addValidator(new Zend_Validate_NotEmpty()); $input->addDecorator($decoratorField); $elements[] = $input; // Add newpass1 field $input = new Zend_Form_Element_Password('newpassword1', array('required' => true, 'label' => 'New Password:'******'id' => 'newpassword1', 'class' => 'form-control', 'placeholder' => 'Your password..')); $input->addValidators(array(new Zend_Validate_Alnum(), new Zend_Validate_StringLength(array('min' => 8)), new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add newpass2 field $input = new Zend_Form_Element_Password('newpassword2', array('required' => true, 'label' => 'New Password Again:', 'id' => 'newpassword2', 'class' => 'form-control', 'placeholder' => 'Your password again..', 'validators' => array(array('identical', false, array('token' => 'newpassword1'))))); $input->addDecorator($decoratorField); $elements[] = $input; //Add Submit button $input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'Update')); $input->addDecorator($decoratorField); $elements[] = $input; $this->addElements($elements); $this->addDisplayGroup(array('oldpassword', 'newpassword1', 'newpassword2', 'submit'), 'displgrp', array('decorators' => array('FormElements'))); }
public function init() { global $mySession; $db = new Db(); # FORM ELEMENT:Public Name # TYPE : text $publicname = new Zend_Form_Element_Text('publicname'); $publicname->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Public name is required'))->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib('class', 'logintextbox'); # FORM ELEMENT:Email ID # TYPE : text $signupemailid = new Zend_Form_Element_Text('signupemailid'); $signupemailid->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Email Id is required'))->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib('class', 'logintextbox'); //->setAttrib("onchange","validval(this.value);") //->setAttrib("onclick","changeborder(this.id);") if (@$_REQUEST['signupemailid'] != "") { $signupemailid->addValidator('EmailAddress', true)->addDecorator('Errors', array('class' => 'errmsg'))->addErrorMessage('Please enter a valid email address'); } # FORM ELEMENT:password # TYPE : text $signuppass = new Zend_Form_Element_Password('signuppass'); $signuppass->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Password is required'))->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib('class', 'logintextbox'); if (@$_REQUEST['signuppass'] != "") { $signuppass->addValidator('StringLength', 0, 6, true)->addErrorMessage('Password must be atleast 6 characters'); } # FORM ELEMENT: confirm password # TYPE : text $signupcnfrmpass = new Zend_Form_Element_Password('signupcnfrmpass'); $signupcnfrmpass->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Confirm Password is required'))->addDecorator('Errors', array('class' => 'errmsg'))->setAttrib('class', 'logintextbox'); if (@$_REQUEST['signupcnfrmpass'] != "") { $signupcnfrmpass->addValidator('StringLength', 0, 6, true)->addErrorMessage('Password must be atleast 6 characters'); } $this->addElements(array($publicname, $signupemailid, $signuppass, $signupcnfrmpass)); }
public function init() { $tr = Zend_Registry::get('tr'); $handle = new Zend_Form_Element_Text('handle'); $handle->setLabel($tr->_('HANDLE')); $handle->setRequired(true); $handle->addValidator('NotEmpty', true, array('messages' => $tr->_('GENERAL_MISSING_TEXT_VALUE'))); $this->addElement($handle); $password = new Zend_Form_Element_Password('password'); $password->setLabel($tr->_('PASSWORD')); $password->setRequired(true); $password->addValidator('NotEmpty', true, array('messages' => $tr->_('GENERAL_MISSING_TEXT_VALUE'))); $this->addElement($password); $password1 = new Zend_Form_Element_Password('password_again'); $password1->setLabel($tr->_('RETYPE') . ' ' . $tr->_('PASSWORD')); $password1->setRequired(true); $password1->addValidator('NotEmpty', true, array('messages' => $tr->_('GENERAL_MISSING_TEXT_VALUE'))); $this->addElement($password1); $this->addElement(new Zend_Form_Element_Submit($tr->_('SUBMIT'))); parent::init(); }
public function init() { $firstnameField = new Zend_Form_Element_Text('firstname'); $firstnameField->addValidator(new Zend_Validate_Alnum()); $firstnameField->setRequired(true); $lastnameField = new Zend_Form_Element_Text('lastname'); $lastnameField->addValidator(new Zend_Validate_Alnum()); $lastnameField->setRequired(true); $emailField = new Zend_Form_Element_Text('email'); $emailField->addValidator(new Zend_Validate_EmailAddress()); $emailField->setRequired(true); $loginField = new Zend_Form_Element_Text('login'); $loginField->addValidator(new Zend_Validate_Alnum()); $loginField->setRequired(true); $teamMapper = new User_Model_Mapper_Team(); $teamArray = $teamMapper->getList(); foreach ($teamArray as $rowTeam) { $teams[$rowTeam->getId()] = $rowTeam->getName(); } $teamField = new Zend_Form_Element_Select('team'); $teamField->addMultiOptions($teams); $idField = new Zend_Form_Element_Hidden('id'); $passwordField = new Zend_Form_Element_Password('password'); $passwordField->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 18))); $submitBtn = new Zend_Form_Element_Submit('submit'); $this->addElements(array($firstnameField, $lastnameField, $emailField, $loginField, $passwordField, $teamField, $idField, $submitBtn)); $this->setAction(''); }
/** create form */ public function createDBForm() { $form = new Zend_Form(); $form->setAction($this->webroot . '/install/step2')->setMethod('post'); $type = new Zend_Form_Element_Hidden('type'); $host = new Zend_Form_Element_Text('host'); $host->setValue('localhost'); $port = new Zend_Form_Element_Text('port'); $port->addValidator('Digits', true); $unixsocket = new Zend_Form_Element_Text('unix_socket'); $dbname = new Zend_Form_Element_Text('dbname'); $dbname->setRequired(true)->addValidator('NotEmpty', true)->setValue('midas'); $username = new Zend_Form_Element_Text('username'); $username->setRequired(true)->addValidator('NotEmpty', true); $password = new Zend_Form_Element_Password('password'); $firstname = new Zend_Form_Element_Text('firstname'); $firstname->setRequired(true)->addValidator('NotEmpty', true); $lastname = new Zend_Form_Element_Text('lastname'); $lastname->setRequired(true)->addValidator('NotEmpty', true); $email = new Zend_Form_Element_Text('email'); $email->setRequired(true)->addValidator('NotEmpty', true)->addValidator('EmailAddress'); $userpassword1 = new Zend_Form_Element_Password('userpassword1'); $userpassword1->addValidator('NotEmpty', true)->setRequired(true); $userpassword2 = new Zend_Form_Element_Password('userpassword2'); $userpassword2->addValidator('NotEmpty', true)->setRequired(true); $gravatar = new Zend_Form_Element_Checkbox('gravatar'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Setup database and account'); $form->addElements(array($type, $host, $port, $unixsocket, $dbname, $username, $password, $firstname, $lastname, $email, $userpassword1, $userpassword2, $gravatar, $submit)); return $form; }
/** * Create user details form (single user). * * @return void */ public function init() { // Invoke the agent user manager $agentUserManager = new Manager_Core_Agent_User(); // Create array of possible security questions $securityQuestions = array('' => '--- please select ---'); $securityQuestions += $agentUserManager->getUserSecurityAllQuestions(); // Add real name element $this->addElement('text', 'realname', array('label' => 'Full name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your full name', 'notEmptyInvalid' => 'Please enter your full name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))))); // Add username element $this->addElement('text', 'username', array('label' => 'Username', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your username', 'notEmptyInvalid' => 'Please enter your username'))), array('regex', true, array('pattern' => '/^[a-z0-9]{1,64}$/i', 'messages' => 'Username must contain between 1 and 64 alphanumeric characters'))))); if ($this->_role == Model_Core_Agent_UserRole::MASTER) { $this->getElement('username')->setRequired(true); } else { $this->getElement('username')->setAttrib('disabled', 'disabled'); } // Add password1 element $passwordElement1 = new Zend_Form_Element_Password('password1'); $passwordElement1->setRequired(false); $passwordElement1->setLabel('New password:'******'password2'); $validator->setMessage('Passwords are not the same', Zend_Validate_Identical::NOT_SAME); $passwordElement1->addValidator($validator); $passwordElement2 = new Zend_Form_Element_Password('password2'); $passwordElement2->setRequired(false); $passwordElement2->setLabel('New password (again)'); $this->addElement($passwordElement2); // Add e-mail element $this->addElement('text', 'email', array('label' => 'E-mail address', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your e-mail address')))))); $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in e-mail address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid e-mail address')); $this->getElement('email')->addValidator($emailValidator); if ($this->_role == Model_Core_Agent_UserRole::MASTER) { $this->getElement('email')->setRequired(true); } else { $this->getElement('email')->setAttrib('disabled', 'disabled'); } // Add e-mail element $this->addElement('text', 'emailcopyto', array('label' => 'Copy e-mail to', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter a copy-to e-mail address')))))); $emailCopyToValidator = new Zend_Validate_EmailAddress(); $emailCopyToValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in copy-to e-mail address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid copy-to e-mail address')); $this->getElement('emailcopyto')->addValidator($emailCopyToValidator); // Add security question element $this->addElement('select', 'question', array('label' => 'Security question', 'required' => false, 'multiOptions' => $securityQuestions)); // Add security answer element $this->addElement('text', 'answer', array('label' => 'Security answer', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', true, array('pattern' => '/^[\\w\\ \\.\\-\'\\,]{2,}$/i', 'messages' => 'Security answer must contain at least two characters and only basic punctuation (hyphen, apostrophe, comma, full stop and space)'))))); // Add master user element $this->addElement('checkbox', 'master', array('label' => 'Master user', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); // Add agent reports element $this->addElement('checkbox', 'reports', array('label' => 'Agent reports', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); // Add status element $this->addElement('checkbox', 'status', array('label' => 'Active', 'required' => false, 'checkedValue' => '1', 'uncheckedValue' => '0')); // Set custom subform decorator $this->setDecorators(array(array('ViewScript', array('viewScript' => 'settings/subforms/useraccount.phtml', 'role' => $this->_role)))); $this->setElementFilters(array('StripTags')); $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); }
public function init() { $this->setAttrib('class', 'form-horizontal'); $login = new Zend_Form_Element_Text('login'); $login->setRequired()->addValidator('StringLength', false, array('max' => 32))->setLabel('Nom d\'utilisateur'); $db = Zend_Db_Table::getDefaultAdapter(); $validator = new Zend_Validate_Db_NoRecordExists(array('adapter' => $db, 'schema' => 'twitter', 'table' => 'membre', 'field' => 'login')); $validator->setMessage("Le login '%value%' est déjà utilisé"); $login->addValidator($validator); $pass = new Zend_Form_Element_Password('pass'); $pass->setLabel('Mot de passe')->setRequired(); $passConfirm = new Zend_Form_Element_Password('confirm'); $passConfirm->setLabel('Confirmer le mot de passe'); $validator = new Zend_Validate_Identical('pass'); $validator->setMessage('La confirmation ne correspond pas au mot de passe'); $passConfirm->addValidator($validator); //$passConfirm->addValidator('Identical', false, array('token')); $hash = new Zend_Form_Element_Hash('hash'); $submit = new Zend_Form_Element_Submit('Inscription'); $cancel = new Zend_Form_Element_Button('Annuler'); $this->addElements(array($login, $pass, $passConfirm, $hash, $submit, $cancel)); // add display group $this->addDisplayGroup(array('login', 'pass', 'confirm', 'Inscription', 'Annuler'), 'users'); $this->getDisplayGroup('users')->setLegend('S\'inscrire'); // set decorators EasyBib_Form_Decorator::setFormDecorator($this, EasyBib_Form_Decorator::BOOTSTRAP, 'Inscription', 'Annuler'); }
public function init() { $this->setMethod('POST'); $defaultArgs = array('disableLoadDefaultDecorators' => true, 'decorators' => array('ViewHelper')); $identity = $this->getAttrib('user_id'); $user_object = Engine_Api::_()->user()->getUser($identity); $user_id = new Zend_Form_Element_Hidden('user_id'); $user_id->setValue($identity); $email = new Zend_Form_Element_Text('email', $defaultArgs); $email->addValidator('emailAddress', true)->addValidator(new Zend_Validate_Db_NoRecordExists(Engine_Db_Table::getTablePrefix() . 'users', 'email')); $email->setValue($user_object->email); $password = new Zend_Form_Element_Password('password', $defaultArgs); $password->addValidator('stringLength', false, array(6, 32)); $passconf = new User_Form_Element_PasswordConfirm('passconf', $defaultArgs); //$passconf->addDecorator('ViewHelper'); if ($settings->getSetting('user.signup.username', 1) > 0) { $username = new Zend_Form_Element_Text('username', $defaultArgs); $username->setValue($user_object->username); $username->addValidator('stringLength', true, array(6, 32))->addValidator(new Zend_Validate_Db_NoRecordExists(Engine_Db_Table::getTablePrefix() . 'users', 'username')); } $language = new Zend_Form_Element_Select('language', $defaultArgs); $language->addMultiOptions(array('English', 'post-English')); $language->setValue($user_object->language_id); $level_id = new Zend_Form_Element_Select('level_id', $defaultArgs); $level_id->setValue($user_object->level_id); $levels = Engine_Api::_()->authorization()->getLevelInfo(); foreach ($levels as $level) { $level_id->addMultiOption($level['level_id'], $level['title']); } $this->addElements(array($user_id, $email, $password, $passconf, $username, $level_id, $language)); }
public function init() { $this->setMethod('post')->setAttrib('id', 'frmRegistrar'); $e = new Zend_Form_Element_Text('nombre'); $e->setRequired(); $e->setLabel('Nombre'); $e->addValidator(new Zend_Validate_StringLength(array('min' => 5, 'max' => 25))); $e->addValidator(new My_Validate_NoX()); $e->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'usuario', 'field' => 'nombre'))); $this->addElement($e); $e = new Zend_Form_Element_Text('login'); $e->setRequired(); $e->setLabel('Login'); $e->addValidator(new Zend_Validate_Alnum()); $e->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'usuario', 'field' => 'login'))); $e->addValidator(new Zend_Validate_StringLength(array('min' => 5, 'max' => 25))); $this->addElement($e); $e = new Zend_Form_Element_Password('pwd'); $e->setRequired(); $e->setLabel('Password'); $this->addElement($e); $e = new Zend_Form_Element_Password('pwd_2'); $e->setRequired(); $e->setLabel('Confirmación Password'); $e->addValidator(new My_Validate_PasswordConfirmation()); $this->addElement($e); $this->addElement('submit', 'Enviar'); }
function getForm() { $form = new Cible_Form(array('disabledDefaultActions' => true)); $base_dir = $this->getFrontController()->getBaseUrl(); $redirect = str_replace($base_dir, '', $this->_request->getParam('redirect')); $form->setAction("{$base_dir}/auth/login")->setMethod('post'); $form->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table')), 'Form')); $form->setAttrib('class', 'auth-form'); $username = new Zend_Form_Element_Text('username'); $username->setLabel(Cible_Translation::getCibleText('form_label_username')); $username->setRequired(true); $username->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => Cible_Translation::getCibleText('error_field_required')))); $username->setAttrib('class', 'loginTextInput'); $username->setDecorators(array('ViewHelper', 'Description', 'Errors', 'Label', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'username')), array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'openOnly' => true)))); $form->addElement($username); $password = new Zend_Form_Element_Password('password'); $password->setLabel(Cible_Translation::getCibleText('form_label_password')); $password->setRequired(true); $password->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => Cible_Translation::getCibleText('error_field_required')))); $password->setAttrib('class', 'loginTextInput'); $password->setDecorators(array('ViewHelper', 'Description', 'Errors', 'Label', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'password')), array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'closeOnly' => true)))); $form->addElement($password); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel(Cible_Translation::getCibleText('button_authenticate'))->setAttrib('class', 'loginButton')->setAttrib('onmouseover', 'this.className=\'loginButtonOver\';')->setAttrib('onmouseout', 'this.className=\'loginButton\';')->removeDecorator('label')->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'colspan' => '2', 'align' => 'right', 'class' => 'submit')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $form->addElement($submit); $redirect_hidden = new Zend_Form_Element_Hidden('redirect'); $redirect_hidden->setValue($redirect)->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'colspan' => '2')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $form->addElement($redirect_hidden); return $form; }
public function init() { $this->setMethod('post'); // $this->setAction('/index/login'); $this->setAttrib('id', 'msform'); $email = new Zend_Form_Element_Text('email'); $email->setAttrib('placeholder', 'E-mail'); $email->setAttrib('autocomplete', 'off'); $email->addFilter('StripTags'); $email->addFilter('HtmlEntities'); $email->addFilter('StringTrim'); $email->setRequired(true)->addErrorMessage('Username Required'); $email->addValidator('EmailAddress')->addErrorMessage('Invalid Email used'); $email->addValidator('StringLength', true, array(0, 255))->addErrorMessage('Required Field'); $password = new Zend_Form_Element_Password('password'); $password->setAttrib('placeholder', 'Password'); $password->setAttrib('autocomplete', 'off'); $password->addFilter('StripTags'); $password->addFilter('HtmlEntities'); $password->addFilter('StringTrim'); $password->setRequired(true)->addErrorMessage('Password Required'); $password->addValidator('StringLength', true, array(0, 255))->addErrorMessage('Required Field'); $link = new Zend_Form_Element_Note('forgot_password', array('value' => '<a href="#" id="link">Forgot your password ?</a>')); $submit = new Zend_Form_Element_Submit('SignIn'); $submit->setLabel('Sign In'); $submit->setAttrib('class', 'btn btn-info'); $register = new Zend_Form_Element_Button('register'); $register->setLabel('Register'); $register->setAttrib('class', 'btn btn-warning'); $this->addElements(array($email, $password, $submit, $register, $link)); $this->setElementDecorators(array('ViewHelper')); $submit->setDecorators(array('ViewHelper')); $register->setDecorators(array('ViewHelper')); $this->setDecorators(array('FormElements', 'Form')); }
public function init() { $nome = new Zend_Form_Element_Text('nome', array('label' => 'Nome:', 'required' => true)); $val = new Zend_Validate_StringLength(array('min' => 10)); $nome->addValidator($val); $upper = new Zend_Filter_StringToUpper(); $nome->addFilter($upper); $this->addElement($nome); $email = new Zend_Form_Element_Text('email', array('label' => 'Email:')); $isEmail = new Zend_Validate_EmailAddress(); $email->addValidator($isEmail); $this->addElement($email); $senha = new Zend_Form_Element_Password('senha', array('label' => 'Senha:', 'required' => true)); $lenghtSenha = new Zend_Validate_StringLength(array('min' => 5, 'max' => 15)); $senha->addValidator($lenghtSenha); $this->addElement($senha); $endereco = new Zend_Form_Element_Text('endereco', array('label' => 'Endereço:')); $this->addElement($endereco); $bairro = new Zend_Form_Element_Text('bairro', array('label' => 'Bairro:')); $this->addElement($bairro); $cep = new Zend_Form_Element_Text('cep', array('label' => 'CEP:')); $this->addElement($cep); $pais = new Zend_Form_Element_Text('pais', array('label' => 'País:')); $this->addElement($pais); $botao = new Zend_Form_Element_Submit('botao', array('label' => 'Salvar')); $this->addElement($botao); }
public function init() { $this->setMethod('post'); //The password element. $passwordElement = new Zend_Form_Element_Password('password'); $passwordElement->setRequired(true); $passwordElement->setLabel('New Password:'******'confirm_password'); $validator->setMessage('Passwords are not the same', Zend_Validate_Identical::NOT_SAME); $passwordElement->addValidator($validator); $this->addElement($passwordElement); //The confirm password element. $confirmPasswordElement = new Zend_Form_Element_Password('confirm_password'); $confirmPasswordElement->setRequired(true); $confirmPasswordElement->setLabel('Confirm New Password:'******'Please confirm your password'); $confirmPasswordElement->addValidator($validator); $this->addElement($confirmPasswordElement); // Security question & answer $this->addElement('select', 'security_question', array('label' => 'Security Question', 'required' => true, 'multiOptions' => array(0 => 'Please select'), 'decorators' => array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))))); $this->addElement('text', 'security_answer', array('label' => 'Answer', 'required' => true, 'filters' => array('StringTrim'), 'attribs' => array('data-ctfilter' => 'yes'))); $this->addElement('hidden', 'instruction', array('required' => false)); $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Save', 'class' => 'button')); $this->setElementDecorators(array('ViewHelper', 'Label', 'Errors', array('HtmlTag', array('tag' => 'div')))); // Set up the decorator on the form and add in decorators which are removed $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'form_section one-col'))->addDecorator('Form'); $element = $this->getElement('submit'); $element->removeDecorator('label'); // Remove the label from the submit button }
public function init() { $this->setName('registerForm'); $this->setMethod('post'); $this->setAction('/user/register/'); $user = new Zend_Form_Element_Text('user'); $user->setLabel('Username'); $user->setRequired(true); $user->addValidator('Alnum', false); $user->addValidator('StringLength', true, array(3, 30)); //$user->addValidator('Db_NoRecordExists', true, array('user', 'user') ); $password = new Zend_Form_Element_Password('password'); $password->setLabel('Password'); $password->setRenderPassword(true); $password->setRequired(true); $password->addValidator('StringLength', true, array(5, 50)); $name = new Zend_Form_Element_Text('name'); $name->setLabel('Full Name'); $name->setRequired(true); $name->addValidator('StringLength', true, array(3, 128)); $email = new Zend_Form_Element_Text('email'); $email->setLabel('Email'); $email->setRequired(true); $email->addValidator('EmailAddress', true); $email->addValidator('StringLength', true, array(3, 128)); $submit = new Zend_Form_Element_Submit('register'); $submit->setLabel('Register'); $hash = new Zend_Form_Element_Hash('hash'); $this->setElements(array($user, $password, $name, $email, $submit, $hash)); }
/** Initialize this form. */ public function init() { $this->setName('ldap_admin'); $this->setMethod('POST'); $csrf = new Midas_Form_Element_Hash('csrf'); $csrf->setSalt('pZyCgKUmRGcsxVdNEtJLrAhW'); $csrf->setDecorators(array('ViewHelper')); $hostName = new Zend_Form_Element_Text(LDAP_HOST_NAME_KEY); $hostName->setLabel('LDAP Server Name'); $hostName->setRequired(true); $hostName->addValidator('NotEmpty', true); $hostName->addValidator('Hostname', true, array('allow' => Zend_Validate_Hostname::ALLOW_ALL, 'tld' => false)); $port = new Zend_Form_Element_Text(LDAP_PORT_KEY); $port->setLabel('LDAP Server Port'); $port->setRequired(true); $port->addValidator('NotEmpty', true); $port->addValidator('Digits', true); $port->addValidator('Between', true, array('min' => 1, 'max' => 65535)); $port->setAttrib('maxlength', 5); $backupServer = new Zend_Form_Element_Text(LDAP_BACKUP_SERVER_KEY); $backupServer->setLabel('Backup Server Name'); $backupServer->addValidator('NotEmpty', true); $backupServer->addValidator('Hostname', true, array('allow' => Zend_Validate_Hostname::ALLOW_ALL, 'tld' => false)); $bindRdn = new Zend_Form_Element_Text(LDAP_BIND_RDN_KEY); $bindRdn->setLabel('Bind DN'); $bindRdn->addValidator('NotEmpty', true); $bindPassword = new Zend_Form_Element_Password(LDAP_BIND_PASSWORD_KEY); $bindPassword->setLabel('Bind Password'); $bindPassword->addValidator('NotEmpty', true); $baseDn = new Zend_Form_Element_Text(LDAP_BASE_DN_KEY); $baseDn->setLabel('Base DN'); $baseDn->setRequired(true); $baseDn->addValidator('NotEmpty', true); $protocolVersion = new Zend_Form_Element_Text(LDAP_PROTOCOL_VERSION_KEY); $protocolVersion->setLabel('LDAP Protocol Version'); $protocolVersion->setRequired(true); $protocolVersion->addValidator('NotEmpty', true); $protocolVersion->addValidator('Digits', true); $protocolVersion->addValidator('GreaterThan', true, array('min' => 1)); $protocolVersion->setAttrib('maxlength', 1); $searchTerm = new Zend_Form_Element_Text(LDAP_SEARCH_TERM_KEY); $searchTerm->setLabel('Search Term'); $searchTerm->setRequired(true); $searchTerm->addValidator('NotEmpty', true); $proxyBaseDn = new Zend_Form_Element_Text(LDAP_PROXY_BASE_DN_KEY); $proxyBaseDn->setLabel('Proxy Base DN'); $proxyBaseDn->addValidator('NotEmpty', true); $proxyPassword = new Zend_Form_Element_Password(LDAP_PROXY_PASSWORD_KEY); $proxyPassword->setLabel('Proxy Password'); $proxyPassword->addValidator('NotEmpty', true); $useActiveDirectory = new Zend_Form_Element_Checkbox(LDAP_USE_ACTIVE_DIRECTORY_KEY); $useActiveDirectory->setLabel('Use Active Directory'); $autoAddUnknownUser = new Zend_Form_Element_Checkbox(LDAP_AUTO_ADD_UNKNOWN_USER_KEY); $autoAddUnknownUser->setLabel('Automatically Add Unknown Users'); $this->addDisplayGroup(array($hostName, $port, $backupServer, $bindRdn, $bindPassword, $baseDn, $protocolVersion, $searchTerm, $proxyBaseDn, $proxyPassword, $useActiveDirectory, $autoAddUnknownUser), 'global'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Save'); $this->addElements(array($csrf, $hostName, $port, $backupServer, $bindRdn, $bindPassword, $baseDn, $protocolVersion, $searchTerm, $proxyBaseDn, $proxyPassword, $useActiveDirectory, $autoAddUnknownUser, $submit)); }
public function init() { /* Form Elements & Other Definitions Here ... */ $this->setMethod("POST"); $uid = new Zend_Form_Element_Hidden("user_id"); //add firstname $f_name = new Zend_Form_Element_Text("f_name"); $f_name->setRequired(); $f_name->setLabel("first Name:"); $f_name->setAttrib("placeholder", "Enter Your first Name"); $f_name->addValidator(new Zend_Validate_Alnum("true")); $f_name->setAttrib("class", "form-control"); $f_name->getDecorator("Label")->setOption("class", "control-label"); $f_name->getDecorator("Errors")->setOption("class", "alert alert-danger"); $f_name->getDecorator("Errors")->setOption("style", " list-style-type:none"); //add lastname $l_name = new Zend_Form_Element_Text("l_name"); $l_name->setRequired(); $l_name->setLabel("Last Name"); $l_name->setAttrib("placeholder", "Enter Your last Name"); $l_name->addValidator(new Zend_Validate_Alnum("true")); $l_name->setAttrib("class", "form-control"); $l_name->getDecorator("Label")->setOption("class", "control-label"); $l_name->getDecorator("Errors")->setOption("class", "alert alert-danger"); $l_name->getDecorator("Errors")->setOption("style", " list-style-type:none"); //add mail $username = new Zend_Form_Element_Text("username"); $username->setRequired(); $username->setLabel("E-Mail"); $username->setAttrib("placeholder", "Enter Your E-Mail"); $username->addValidator(new Zend_Validate_EmailAddress()); $username->getDecorator("Label")->setOption("class", "control-label"); $username->getDecorator("Errors")->setOption("class", "alert alert-danger"); $username->getDecorator("Errors")->setOption("style", " list-style-type:none"); $password = new Zend_Form_Element_Password("password"); $password->setRequired(); $password->setLabel("Password"); $password->setAttrib("placeholder", "Enter Your Password"); $password->setAttrib("class", "form-control"); $password->getDecorator("Label")->setOption("class", "control-label"); $password->getDecorator("Errors")->setOption("class", "alert alert-danger"); $password->getDecorator("Errors")->setOption("style", " list-style-type:none"); $re_password = new Zend_Form_Element_Password("re_password"); $re_password->setRequired(); $re_password->setLabel("Retype Your Password"); $re_password->addValidator('identical', false, array('token' => 'password')); $re_password->setAttrib("placeholder", "Re-enter Your Password"); $re_password->setAttrib("class", "form-control"); $re_password->getDecorator("Label")->setOption("class", "control-label"); $re_password->getDecorator("Errors")->setOption("class", "alert alert-danger"); $re_password->getDecorator("Errors")->setOption("style", " list-style-type:none"); $submit = new Zend_Form_Element_Submit("submit"); $submit->setAttrib("class", "btn btn-xl center-block"); $this->addElements(array($uid, $f_name, $l_name, $username, $password, $re_password, $submit)); }
public function init() { $loginField = new Zend_Form_Element_Text('login'); $loginField->addValidator(new Zend_Validate_Alnum()); $loginField->setRequired(true); $passwordField = new Zend_Form_Element_Password('password'); $passwordField->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 18))); $submitBtn = new Zend_Form_Element_Submit('submit'); $this->addElements(array($loginField, $passwordField, $submitBtn)); $this->setAction('/User/auth/login'); }
/** * Creates the registration form and it's elements. * Also sets the validation techniques for the fields */ function __construct() { parent::__construct(); $this->setName('Registration'); $this->setMethod('POST'); $this->setAction('/user/register'); $username = new Zend_Form_Element('username'); $username->setLabel('Username'); $username->setRequired(true); $username->addValidator('NotEmpty', true); $username->addValidator(new Zend_Validate_StringLength(6, 10), true); $username->addValidator('Alnum', true); $username->addValidator(new User_Models_Forms_Validators_IsUnique('username')); $password = new Zend_Form_Element_Password('password'); $password->setLabel('Password'); $password->setRequired(true); $password->addValidator('NotEmpty', true); $password->addValidator(new Zend_Validate_StringLength(6, 10)); $gender = new Zend_Form_Element_Select('gender'); $gender->setLabel('Gender'); $gender->setMultiOptions(array('Male' => 'Male', 'Female' => 'Female')); $email = new Zend_Form_Element_Text('email'); $email->setLabel('Email'); $email->setRequired(true); $email->addValidator('NotEmpty', true); $email->addValidator(new User_Models_Forms_Validators_EmailAddress(), true); $email->addValidator(new User_Models_Forms_Validators_IsUnique('email')); $paymentEmail = new Zend_Form_Element_Text('paymentEmail'); $paymentEmail->setLabel('Payment Email'); $paymentEmail->setRequired(true); $paymentEmail->addValidator('NotEmpty', true); $paymentEmail->addValidator(new User_Models_Forms_Validators_EmailAddress(), true); $paymentEmail->addValidator(new User_Models_Forms_Validators_IsUnique('paymentEmail')); $countries = new Zend_Form_Element_Select('country'); $countries->setMultiOptions(self::getCountries()); $countries->setLabel('Country'); $countries->addValidator('NotEmpty'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Register'); $this->addElements(array($username, $password, $gender, $email, $paymentEmail, $countries, $submit)); }
function __construct() { parent::__construct(); $this->setName('Registration'); $this->setMethod('POST'); $this->setAction('/user/login'); $username = new Zend_Form_Element('username'); $username->setLabel('Username'); $username->setRequired(true); $username->addValidator('NotEmpty', true); $username->addValidator(new Zend_Validate_StringLength(6, 10)); $username->addValidator('Alnum', true); $password = new Zend_Form_Element_Password('password'); $password->setLabel('Password'); $password->setRequired(true); $password->addValidator('NotEmpty', true); $password->addValidator(new Zend_Validate_StringLength(6, 10)); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Register'); $this->addElements(array($username, $password, $submit)); }
public function init() { $this->setName(strtolower(get_class())); $this->setMethod("post"); $oFormName = new Zend_Form_Element_Hidden("form_name"); $oFormName->setValue(get_class()); $oFormName->setIgnore(FALSE)->removeDecorator("Label"); $this->addElement($oFormName); $oOldPassword = new Zend_Form_Element_Password("old_password"); $oOldPassword->addValidator(new Zend_Validate_Alnum()); $oOldPassword->setLabel("Stare hasło:")->setRequired(TRUE); $oOldPassword->setAttrib("class", "valid"); $this->addElement($oOldPassword); $oNewPassword = new Zend_Form_Element_Password("new_password"); $oNewPassword->addValidator(new Zend_Validate_Alnum()); $oNewPassword->setLabel("Nowe hasło:")->setRequired(TRUE); $oNewPassword->setAttrib("class", "valid"); $this->addElement($oNewPassword); $oNewPasswordConfirm = new Zend_Form_Element_Password("new_password_confirm"); $oNewPasswordConfirm->addValidator(new AppCms2_Validate_PasswordConfirmation()); $oNewPasswordConfirm->addValidator(new Zend_Validate_Alnum()); $oNewPasswordConfirm->setLabel("Powtórz nowe hasło:")->setRequired(TRUE); $oNewPasswordConfirm->setAttrib("class", "valid"); $this->addElement($oNewPasswordConfirm); $this->addElement("hash", "csrf_token", array("ignore" => false, "timeout" => 7200)); $this->getElement("csrf_token")->removeDecorator("Label"); $oSubmit = $this->createElement("submit", "submit"); $oSubmit->setLabel("Zapisz"); $this->addElement($oSubmit); $oViewScript = new Zend_Form_Decorator_ViewScript(); $oViewScript->setViewModule("admin"); $oViewScript->setViewScript("_forms/changepassword.phtml"); $this->clearDecorators(); $this->setDecorators(array(array($oViewScript))); $oElements = $this->getElements(); foreach ($oElements as $oElement) { $oElement->setFilters($this->_aFilters); $oElement->removeDecorator("Errors"); } }
public function __construct($options = null, $memberOfGroups = array(), $modeEdit = false) { parent::__construct($options); // get request $request = UsersFormOp::getParams('request'); $this->setAttrib('accept-charset', 'UTF-8'); $this->setName('users'); $this->setAction('/publicms/profile/processuser/format/json'); $id = new Zend_Form_Element_Hidden('id'); $module = new Zend_Form_Element_Hidden('module'); $module->setValue($request->module); $controller = new Zend_Form_Element_Hidden('controller'); $controller->setValue($request->controller); $login = new Zend_Form_Element_Text('login'); $login->setLabel('E-mail'); $login->addValidator(new Zend_Validate_EmailAddress()); //$login->setDescription('Must be a valid e-mail address'); if ($modeEdit) { $login->setAttrib('disabled', true); $login->setAttrib('readonly', true); } else { $login->setRequired(); } /** * Password field * @var void */ $password = new Zend_Form_Element_Password('password'); $password->setLabel('password'); $password->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12))); $password2 = new Zend_Form_Element_Password('password2'); $password2->setLabel('password2'); $this->password = $password; $this->password2 = $password2; if (!$modeEdit) { $password->setRequired(); $password2->setRequired(); } $fileName = new Zend_Form_Element_Text('fname'); $fileName->setLabel('fname'); $fileName->setRequired(); $lastName = new Zend_Form_Element_Text('lname'); $lastName->setLabel('lname'); $lastName->setRequired(); $submit = new Zend_Form_Element_Submit('submit', 'Save user'); $submit->setAttrib('id', 'submitbuttonuser'); // Init list of elements $elementsList[0] = array($login, $password, $password2); $elementsList[1] = array($fileName, $lastName, $submit, $id, $module, $controller); $this->addElements($elementsList[0]); $this->addElements($elementsList[1]); }
public function init() { // Set request method $this->setMethod('post'); // Email entry $this->addElement('span', 'email', array('label' => 'Email address', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'formvalue', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your email address')))))); // Modify email error messages & add validator $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address")); $this->getElement('email')->addValidator($emailValidator); //The password element. $passwordElement = new Zend_Form_Element_Password('password'); $passwordElement->setRequired(true); $passwordElement->setLabel('Create your password'); $passwordElement->setOptions(array('data-noAjaxValidate' => '1')); $passwordElement->addValidator(new Zend_Validate_PasswordStrength()); $validator = new Zend_Validate_Identical(); $validator->setToken('confirm_password'); $validator->setMessage('Passwords are not the same', Zend_Validate_Identical::NOT_SAME); $passwordElement->addValidator($validator); $this->addElement($passwordElement); //The confirm password element. $confirmPasswordElement = new Zend_Form_Element_Password('confirm_password'); $confirmPasswordElement->setRequired(true); $confirmPasswordElement->setLabel('Re-enter password'); $confirmPasswordElement->setOptions(array('data-noAjaxValidate' => '1')); $validator = new Zend_Validate_NotEmpty(); $validator->setMessage('Please confirm your password'); $confirmPasswordElement->addValidator($validator); $this->addElement($confirmPasswordElement); // Security question & answer $securityQuestionModel = new Datasource_Core_SecurityQuestion(); $securityQuestionOptions = array(0 => '- Please Select -'); foreach ($securityQuestionModel->getOptions() as $option) { $securityQuestionOptions[$option['id']] = $option['question']; } $this->addElement('select', 'security_question', array('label' => 'Security Question', 'required' => false, 'multiOptions' => $securityQuestionOptions, 'decorators' => array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))))); /* Value no longer mandatory, Redmine #11873 $questionElement = $this->getElement('security_question'); $validator = new Zend_Validate_GreaterThan(array('min'=> 0)); $validator->setMessage('You must select a security question'); $questionElement->addValidator($validator); */ $this->addElement('text', 'security_answer', array('label' => 'Answer', 'required' => false, 'filters' => array('StringTrim'))); // Set custom subform decorator - this is the default and gets overridden by view scripts in the tenants' and landlords' Q&Bs $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/register.phtml')))); // Set element decorators $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); // Grab view and add the client-side password validation JavaScript into the page head $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view'); $view->headScript()->appendFile('/assets/common/js/passwordValidation.js', 'text/javascript'); }
public function init() { /* $email = $this->addElement('text', 'email', array( 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array( 'EmailAddress', ), 'required' => true, 'label' => $this->translate->_("Email"), 'decorators' => $this->elementDecorators, 'description'=>"mustbe lower..." )); */ $email = new Zend_Form_Element_Text("email"); $email->setLabel('Email'); $email->setDecorators($this->elementDecorators); $email->addValidator("EmailAddress"); $email->addValidator("ExistUser", false, array("email")); $email->addPrefixPath('VC_Validate', 'VC/Validate/', 'validate'); $this->addElements(array($email)); /*$username = $this->addElement('text', 'username', array( 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array( 'Alpha', array('StringLength', false, array(3, 20)), ), 'required' => true, 'label' => $this->translate->_("Username"), 'decorators' => $this->elementDecorators, )); */ $token = $this->addElement('hidden', 'token', array('disableLoadDefaultDecorators' => true)); $password = $this->addElement('password', 'password', array('filters' => array('StringTrim'), 'validators' => array(array('StringLength', false, array(6, 20))), 'required' => true, 'label' => $this->translate->_("Password"), 'decorators' => $this->elementDecorators)); /* $re_password = $this->addElement('password', 'password_confirm', array( 'filters' => array('StringTrim'), 'validators' => array( array('SL_ValidatorMatch', false, array("password")), ), 'required' => true, 'label' => $this->translate->_("Confirm password"), 'decorators' => $this->elementDecorators, )); */ $re_password = new Zend_Form_Element_Password("password_confirm"); $re_password->setLabel('Confirm Password'); $re_password->setDecorators($this->elementDecorators); $re_password->addValidator("PasswordConfirmation", false, array("password")); $re_password->addPrefixPath('VC_Validate', 'VC/Validate/', 'validate'); $this->addElements(array($re_password)); $username = $this->addElement('text', 'fullname', array('filters' => array('StringTrim'), 'validators' => array(array('StringLength', false, array(3, 70))), 'required' => true, 'label' => $this->translate->_("Full name"), 'decorators' => $this->elementDecorators)); // Add a captcha $this->addElement('captcha', 'captcha', array('label' => $this->translate->_("Please enter the 5 letters displayed below:"), 'required' => true, 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 5, 'timeout' => 300))); $login = $this->addElement('submit', 'login', array('required' => false, 'ignore' => true, 'label' => $this->translate->_("Register"), 'decorators' => $this->buttonDecorators)); }
public function init() { $this->name = new Zend_Form_Element_Text('name'); $this->new_password = new Zend_Form_Element_Password('new_password'); $this->confirm_password = new Zend_Form_Element_Password('confirm_password'); $this->email = new Zend_Form_Element_Text('email'); $this->biography = new Zend_Form_Element_Textarea('biography'); $this->submit = new Zend_Form_Element_Submit('submit'); $email_validator = new Zend_Validate_EmailAddress(); $email_validator->setDeepMxCheck(false); $email_validator->setDomainCheck(false); $email_validator->setMessages(array(Zend_Validate_EmailAddress::INVALID_FORMAT => "Format Email Salah")); $confirm_password_validator = new Zend_Validate_Identical(); $confirm_password_validator->setMessage("Kata sandi tidak cocok."); $this->biography->setAttribs(array('style' => 'width:100%;height:240px')); $this->name->setAttribs(array('class' => 'span6', 'placeholder' => 'Nama lengkap anda')); $this->email->addValidator($email_validator)->setAttribs(array('class' => 'span4', 'placeholder' => '*****@*****.**')); $this->submit->setAttribs(array('class' => 'btn btn-success'))->setLabel('Simpan'); $this->confirm_password->addValidator($confirm_password_validator); $this->addElements(array($this->name, $this->new_password, $this->confirm_password, $this->email, $this->biography, $this->submit)); $this->setElementDecorators(array('ViewHelper', 'Errors')); }
private function _repetirNovaSenha() { $e = new Zend_Form_Element_Password('repetir_nova_senha'); $e->setRequired(true); $e->addFilter('StripTags'); $e->addFilter('StringTrim'); $e->setAttrib('data-parsley-required', 'true'); $e->setAttrib('data-parsley-equalto', '#nova_senha'); $e->addValidator('stringLength', false, array(6, 15)); $e->setAttrib('placeholder', _('Repeat New Password')); $e->setAttrib('class', 'form-control input-lg'); return $e; }
/** * Initialise the form * * @todo Validation * @return void */ public function init() { // Set request method $this->setMethod('POST'); // Add title element $this->addElement('select', 'title', array('label' => 'Title', 'required' => true, 'multiOptions' => TenantsInsuranceQuote_Form_Subforms_PersonalDetails::$titles, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your title', 'notEmptyInvalid' => 'Please select your title')))), 'class' => 'form-control')); // Add first name element $this->addElement('text', 'first_name', array('label' => 'First name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your first name', 'notEmptyInvalid' => 'Please enter your first name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'First name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))), 'class' => 'form-control')); // Add last name element $this->addElement('text', 'last_name', array('label' => 'Last name', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your last name'))), array('regex', true, array('pattern' => '/^[a-z\\-\\ \']{2,}$/i', 'messages' => 'Last name must contain at least two alphabetic characters and only basic punctuation (hyphen, space and single quote)'))), 'class' => 'form-control')); // Email element $this->addElement('text', 'email', array('label' => 'Email Address', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Email address is required')))), 'class' => 'form-control')); // Modify email error messages & add validator $emailValidator = new Zend_Validate_EmailAddress(); $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => "Domain name invalid in email address", Zend_Validate_EmailAddress::INVALID_FORMAT => "Invalid email address")); $this->getElement('email')->addValidator($emailValidator); //The password element. $passwordElement = new Zend_Form_Element_Password('password', array('validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Password is required')))), 'class' => 'form-control')); $passwordElement->setRequired(true); $passwordElement->setLabel('Password'); $passwordElement->setAttribs(array('class' => 'form-control')); $passwordElement->addValidator(new Zend_Validate_PasswordStrength()); $validator = new Zend_Validate_Identical(); $validator->setToken('confirm_password'); $validator->setMessage('Passwords are not the same', Zend_Validate_Identical::NOT_SAME); $passwordElement->addValidator($validator); $this->addElement($passwordElement); //The confirm password element. $confirmPasswordElement = new Zend_Form_Element_Password('confirm_password'); $confirmPasswordElement->setRequired(true); $confirmPasswordElement->setLabel('Confirm Password'); $confirmPasswordElement->setAttribs(array('class' => 'form-control')); $validator = new Zend_Validate_NotEmpty(); $validator->setMessage('Please confirm your password'); $confirmPasswordElement->addValidator($validator); $this->addElement($confirmPasswordElement); // Security question & answer $this->addElement('select', 'security_question', array('label' => 'Security Question', 'required' => true, 'multiOptions' => array('' => 'Please select'), 'decorators' => array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false))), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Security question is required')))), 'class' => 'form-control')); $this->addElement('text', 'security_answer', array('label' => 'Answer', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Security answer is required')))), 'class' => 'form-control')); $this->addElement('hidden', 'refno', array('required' => false, 'class' => 'noalt')); // Add the submit button $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Register', 'class' => 'btn btn-primary pull-right')); // Set up the element decorators $this->setElementDecorators(array('ViewHelper', 'Label', 'Errors')); // Set up the decorator on the form and add in decorators which are removed $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'form_section'))->addDecorator('Form'); // Remove the label from the submit button $element = $this->getElement('submit'); $element->removeDecorator('label'); $this->getElement('refno')->removeDecorator('HtmlTag'); }
public function init() { $this->setMethod('post'); $this->setAction(BASE_URL . 'dashboard/editpassword'); $this->setAttrib('id', 'formid'); $this->setAttrib('name', 'editpassword'); $id = new Zend_Form_Element_Hidden('id'); $oldPassword = new Zend_Form_Element_Password('password'); $oldPassword->setAttrib('size', 20); $oldPassword->addValidator('NotEmpty', false, array('messages' => 'Please enter current password.')); $oldPassword->setAttrib('maxLength', 15); $oldPassword->setRequired(true); $oldPassword->addFilters(array('StringTrim')); $newPassword = new Zend_Form_Element_Password('newpassword'); $newPassword->setAttrib('size', 20); $newPassword->setAttrib('maxLength', 15); $newPassword->setRequired(true); $newPassword->addValidator('NotEmpty', false, array('messages' => 'Please enter new password.')); $newPassword->addValidator('stringLength', true, array('min' => 6, 'max' => 15, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'The password cannot be more than 15 characters.', Zend_Validate_StringLength::TOO_SHORT => 'New password should be atleast 6 characters long.'))); $newPassword->addFilters(array('StringTrim')); $newPasswordAgain = new Zend_Form_Element_Password('passwordagain'); $newPasswordAgain->setAttrib('size', 20); $newPasswordAgain->setAttrib('maxLength', 15); $newPasswordAgain->setRequired(true); $newPasswordAgain->addValidator('NotEmpty', false, array('messages' => 'Please enter confirm password.')); $newPasswordAgain->addValidator('stringLength', true, array('min' => 6, 'max' => 15, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'The password cannot be more than 15 characters.', Zend_Validate_StringLength::TOO_SHORT => 'Confirm password should be atleast 6 characters long.'))); $newPasswordAgain->addFilters(array('StringTrim')); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $submit->setLabel('Save'); $url = "'dashboard/editpassword/format/json'"; $dialogMsg = "''"; $toggleDivId = "''"; $jsFunction = "''"; $submit->setOptions(array('onclick' => "saveDetails({$url},{$dialogMsg},{$toggleDivId},{$jsFunction});")); $this->addElements(array($id, $oldPassword, $newPassword, $newPasswordAgain, $submit)); $this->setElementDecorators(array('ViewHelper')); }