本文整理汇总了PHP中Zend_Form_Element_Password::setLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Password::setLabel方法的具体用法?PHP Zend_Form_Element_Password::setLabel怎么用?PHP Zend_Form_Element_Password::setLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element_Password
的用法示例。
在下文中一共展示了Zend_Form_Element_Password::setLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($options = null)
{
$this->_disabledDefaultActions = true;
$this->_addRequiredAsterisks = false;
parent::__construct($options);
$baseDir = $this->getView()->baseUrl();
$this->getView()->headLink()->appendStylesheet("{$this->getView()->baseUrl()}/themes/default/css/login.css", 'all');
$this->setAttrib('class', 'login');
$regexValidate = new Cible_Validate_Email();
$regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch');
$email = new Zend_Form_Element_Text('email');
$email->setLabel($this->getView()->getClientText('login_form_email_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setAttrib('class', 'loginTextInput');
$this->addElement($email);
$password = new Zend_Form_Element_Password('password');
$password->setLabel($this->getView()->getClientText('login_form_password_label'))->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'loginTextInput')->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))));
$this->addElement($password);
// checkbox for client persistance
$status = new Zend_Form_Element_Checkbox('stayOn');
$status->setLabel($this->getView()->getClientText('login_form_stayOn_label'));
$status->setValue(1);
$status->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd'))));
$this->addElement($status);
// Submit button
$submit = new Zend_Form_Element_Submit('submit_login');
$submit->setLabel('')->setAttrib('class', 'subscribeButton-' . Zend_Registry::get("languageSuffix"));
$submit->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd'))));
$this->addElement($submit);
$this->setAttrib('class', 'login-form');
}
示例2: init
public function init()
{
$this->setName('Form User Edit');
$this->setAttrib('class', 'Form_Edit');
$this->setMethod('post')->setAction('/user/save');
$id = new Zend_Form_Element_Hidden('id');
$name = new Zend_Form_Element_Text('name');
$name->setLabel('Name:')->setRequired(true)->addValidator('alnum')->addValidator('regex', false, array('/^[a-z]+/'))->addValidator('stringLength', false, array(4, 12))->addFilter('StringToLower');
$pwd = new Zend_Form_Element_Password('pwd');
$pwd->setLabel('Password:')->setRequired(true);
$re_pwd = new Zend_Form_Element_Password('re_pwd');
$re_pwd->setLabel('Re-password:')->setRequired(true);
$role = new Zend_Form_Element_Select('role');
$role->setLabel('Role:')->addMultiOptions(array(array('key' => 'guest', 'value' => 'Guest'), array('key' => 'memeber', 'value' => 'Member'), array('key' => 'admin', 'value' => 'Admin')))->setDescription('Choose one role');
$truename = new Zend_Form_Element_Text('true_name');
$truename->setLabel('Real Name:');
$phone = new Zend_Form_Element_Text('cellphone');
$phone->setLabel('Cell Phone:')->addValidator(new SP_Validate_CellPhone());
$btnSubmit = new Zend_Form_Element_Submit('submit');
$btnSubmit->setLabel('Submit');
$this->addElements(array($id, $name, $pwd, $re_pwd, $role, $truename, $phone, $btnSubmit));
parent::init();
$this->addDecorator('OuterBox', array('attrs' => array('class' => 'form user_edit_form'), 'title' => 'Edit/Create User', 'placement' => 'PREPEND'));
$id->removeDecorator('Label');
$btnSubmit->removeDecorator('Label');
}
示例3: getForm
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;
}
示例4: init
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();
}
示例5: init
/**
* 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));
}
示例6: init
public function init()
{
// initialize form
$this->setAction('/signup')->setMethod('post');
$firstname = new Zend_Form_Element_Text('FirstName');
$firstname->setLabel('First name:')->setOptions(array('size' => '35'))->setRequired(true)->addValidator('NotEmpty', true)->addValidator('Alpha', true)->addFilter('HtmlEntities')->addFilter('StringTrim');
$lastname = new Zend_Form_Element_Text('LastName');
$lastname->setLabel('Last name:')->setOptions(array('size' => '35'))->setRequired(true)->addValidator('NotEmpty', true)->addValidator('Alpha', true)->addFilter('HtmlEntities')->addFilter('StringTrim');
// create text input for email address
$email = new Zend_Form_Element_Text('Email');
$email->setLabel('Email address:');
$email->setOptions(array('size' => '50'))->setRequired(true)->addValidator('NotEmpty', true)->addValidator('EmailAddress', true)->addFilter('HtmlEntities')->addFilter('StringToLower')->addFilter('StringTrim');
// create text input for name
$UserName = new Zend_Form_Element_Text('UserName');
$UserName->setLabel('Username:')->setOptions(array('size' => '50'))->setRequired(true)->addValidator('Alnum')->addFilter('HtmlEntities')->addFilter('StringTrim');
// create text input for password
$Password = new Zend_Form_Element_Password('Password');
$Password->setLabel('Password:')->setOptions(array('size' => '50'))->setRequired(true)->addValidator('NotEmpty', true)->addFilter('HtmlEntities')->addFilter('StringTrim');
// create text input for password confirmation
$ConfirmPassword = new Zend_Form_Element_Password('ConfirmPassword');
$ConfirmPassword->setLabel('Confirm Password:')->setOptions(array('size' => '50'))->setRequired(true)->addValidator('NotEmpty', true)->addFilter('HtmlEntities')->addFilter('StringTrim');
// create submit button
$submit = new Zend_Form_Element_Submit('register');
$submit->setLabel('Register')->setOptions(array('class' => 'submit'));
// attach elements to form
$this->addElement($firstname)->addElement($lastname)->addElement($email)->addElement($UserName)->addElement($Password)->addElement($ConfirmPassword)->addElement($submit);
}
示例7: init
/**
* 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:');
$passwordElement1->addValidator(new Zend_Validate_PasswordStrength());
$this->addElement($passwordElement1);
$validator = new Zend_Validate_Identical();
$validator->setToken('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))));
}
示例8: init
/**
* Form init
*
*/
public function init()
{
$this->setMethod('post');
$this->addElement('text', 'first_name', array('label' => 'First Name*', 'placeholder' => 'e.g. John', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim')));
$this->addElement('text', 'last_name', array('label' => 'Last Name*', 'placeholder' => 'e.g. Smith', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim')));
//http://stackoverflow.com/questions/8014011/queyring-database-for-existing-username-with-zend-and-doctrine
$this->addElement('text', 'username', array('label' => 'Username*', 'placeholder' => 'e.g. smithj01', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('StringLength', true, array('min' => 4, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'Account username must be at least %min% characters'))), array('Regex', true, array('pattern' => '/^\\w(?:[\\w\\d\\.\\-_]+)(?:\\w|\\d)$/', 'messages' => array(Zend_Validate_Regex::NOT_MATCH => "The username contained invalid characters"))))));
$frmPassword1 = new Zend_Form_Element_Password('password', 'password', array('validators' => array(array('StringLength', false, array('min' => 6, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'Password must be at least %min% characters long.'))))));
$frmPassword1->setLabel('Password*')->setAttrib('class', 'col-md-7 col-xs-1 form-control input')->setRequired('true')->addFilter(new Zend_Filter_StringTrim());
//->addValidator('StringLength', false, array(6, 20))
$this->addElement($frmPassword1);
$frmPassword2 = new Zend_Form_Element_Password('confirm_password');
$frmPassword2->setLabel('Confirm Password*')->setAttrib('class', 'col-md-7 col-xs-1 form-control input')->setRequired('true')->addFilter(new Zend_Filter_StringTrim())->addValidator('StringLength', false, array(6, 20))->addValidator(new Zend_Validate_Identical('password'));
$this->addElement($frmPassword2);
// $this->addElement('text', 'password', array(
// 'label' => 'Password (Visible!)*',
// 'class' => 'input',
// 'required' => true,
// 'filters' => array('StringTrim'),
// 'validators' => array(
// array('validator' => 'StringLength', 'options' => array(6, 20))
// )
// ));
$this->addElement('select', 'role', array('label' => 'Role*', 'class' => 'input', 'required' => true, 'filters' => array('StringTrim'), 'multiOptions' => array('reviewer' => 'reviewer', 'admin' => 'admin')));
$fileUploader = new Zend_Form_Element_File('photo');
$fileUploader->setLabel('Photo (max 2MB, JPEG)')->setAttrib('class', 'input')->setDestination(Zend_Registry::get('uploadPath'));
$fileUploader->addValidator('Count', false, 1);
$fileUploader->addValidator('Size', false, 2048000);
$fileUploader->addValidator('Extension', false, 'jpg,jpeg');
$this->addElement($fileUploader, 'photo');
$this->addElement('submit', 'submit', array('ignore' => true, 'class' => 'submit', 'label' => 'Add User'));
}
示例9: init
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');
}
示例10: init
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');
}
示例11: init
/**
*
* Change password form
*
*/
public function init()
{
$cname = explode('_', get_class());
$this->preInit(end($cname));
// use template file
$this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/ChangePassword.phtml'))));
$Profiles = new Application_Model_Profiles();
// fields
$password_old = new Zend_Form_Element_Password('passwordold');
$password_old->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('autocomplete', 'off')->setRequired(true)->setErrorMessages(array($this->translator->translate('Password is required')))->setLabel($this->translator->translate('Old Password:'))->setAttrib('class', 'form-control');
// check if blank password (facebook-registered user) and remove old password field if so
if (Zend_Auth::getInstance()->hasIdentity()) {
$profile = $Profiles->getProfile(Zend_Auth::getInstance()->getIdentity()->name);
if ($profile->password == '') {
$password_old->setAttrib('class', 'hidden');
$password_old->setRequired(false);
$password_old->setLabel('');
}
}
$password1 = new Zend_Form_Element_Password('password1');
$password1->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('autocomplete', 'off')->setRequired(true)->addValidator('StringLength', false, array(5))->setErrorMessages(array($this->translator->translate('Min 5 characters')))->setLabel($this->translator->translate('New Password:'))->setAttrib('class', 'form-control');
$password2 = new Zend_Form_Element_Password('password2');
$password2->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('autocomplete', 'off')->setRequired(true)->addValidator('Identical', false, array('token' => 'password1'))->setErrorMessages(array($this->translator->translate('The passwords do not match')))->setLabel($this->translator->translate('Confirm Password:'))->setAttrib('class', 'form-control');
$submit = new Zend_Form_Element_Submit('changepass');
$submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Change Password'))->setAttrib('class', 'submit btn btn-default');
$this->addElements(array($password_old, $password1, $password2, $submit));
$this->postInit();
}
示例12: init
public function init()
{
$this->setMethod('post');
//The password element.
$passwordElement = new Zend_Form_Element_Password('password');
$passwordElement->setRequired(true);
$passwordElement->setLabel('New Password:');
$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 New Password:');
$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(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
}
示例13: init
/**
* Form initialization
*
* @return void
*/
public function init()
{
$this->addElementPrefixPath('Users_Form_Auth_Validate', dirname(__FILE__) . "/Validate", 'validate');
$this->setName('userRegisterForm');
$username = new Zend_Form_Element_Text('login');
$username->setLabel('User name')->addDecorators($this->_inputDecorators)->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('Alnum')->addValidator('StringLength', false, array(Users_Model_User::MIN_USERNAME_LENGTH, Users_Model_User::MAX_USERNAME_LENGTH))->addValidator('Db_NoRecordExists', false, array(array('table' => 'users', 'field' => 'login')));
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password')->addDecorators($this->_inputDecorators)->setRequired(true)->setValue(null)->addValidator('StringLength', false, array(Users_Model_User::MIN_PASSWORD_LENGTH))->addValidator('PasswordConfirmation');
$confirmPassword = new Zend_Form_Element_Password('password2');
$confirmPassword->setLabel('Password again')->addDecorators($this->_inputDecorators)->setRequired(true)->setValue(null)->addValidator('StringLength', false, array(Users_Model_User::MIN_PASSWORD_LENGTH));
$email = new Zend_Form_Element_Text('email');
$email->setLabel('Email')->addDecorators($this->_inputDecorators)->setRequired(true)->setValue(null)->addValidator('StringLength', false, array(6))->addValidator('EmailAddress')->addValidator('Db_NoRecordExists', false, array(array('table' => 'users', 'field' => 'email')));
$imgDir = dirname(APPLICATION_PATH) . "/public/captcha";
// check captcha path is writeable
if (is_writable($imgDir)) {
$captcha = new Zend_Form_Element_Captcha('captcha', array('label' => "Please verify you're a human", 'captcha' => 'Image', 'captchaOptions' => array('captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'imgDir' => $imgDir, 'imgUrl' => '/captcha/', 'font' => dirname(APPLICATION_PATH) . "/data/fonts/Aksent_Normal.ttf")));
} else {
$captcha = new Zend_Form_Element_Captcha('captcha', array('label' => "Please verify you're a human", 'captcha' => 'Figlet', 'captchaOptions' => array('wordLen' => 6, 'timeout' => 300)));
}
$captcha->addDecorators($this->_inputDecorators);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Register');
$submit->setAttrib('class', 'btn btn-primary');
$this->addElements(array($username, $password, $confirmPassword, $email, $captcha, $submit));
return $this;
}
示例14: init
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));
}
示例15: init
public function init()
{
$this->clearDecorators();
$this->addElementPrefixPath('Pas_Validate', 'Pas/Validate/', 'validate');
$this->addPrefixPath('Pas_Form_Element', 'Pas/Form/Element/', 'element');
$decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li')), array('Label', array('separator' => ' ', 'requiredSuffix' => ' *', 'class' => 'leftalign')), array('HtmlTag', array('tag' => 'li')));
$oldpassword = new Zend_Form_Element_Password('oldpassword');
$oldpassword->setLabel('Your old password: ');
$oldpassword->setRequired(true)->addValidator('RightPassword')->addFilters(array('StripTags', 'StringTrim'));
$oldpassword->setDecorators($decorators);
$password = new Zend_Form_Element_Password("password");
$password->setLabel("New password:")->addValidator("NotEmpty")->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->setDecorators($decorators)->addValidator('IdenticalField', false, array('password2', ' confirm password field'));
// identical field validator with custom messages
$hash = new Zend_Form_Element_Hash('csrf');
$hash->setValue($this->_config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(60);
$this->addElement($hash);
$password2 = new Zend_Form_Element_Password("password2");
$password2->setLabel("Confirm password:")->addValidator("NotEmpty")->addFilters(array('StripTags', 'StringTrim'))->setRequired(true)->setDecorators($decorators);
$submit = new Zend_Form_Element_Submit('submit');
$submit->clearDecorators();
$submit->addDecorators(array(array('ViewHelper'), array('HtmlTag', array('tag' => 'div', 'class' => 'submit'))));
$submit->setAttrib('class', 'large')->setLabel('Change password');
$this->addElement($submit);
$this->addElements(array($oldpassword, $password, $password2, $submit));
$this->addDisplayGroup(array('oldpassword', 'password', 'password2'), 'userdetails');
$this->addDecorator('FormElements')->addDecorator(array('ListWrapper' => 'HtmlTag'), array('tag' => 'div'))->addDecorator('FieldSet')->addDecorator('Form');
$this->userdetails->removeDecorator('DtDdWrapper');
$this->userdetails->removeDecorator('FieldSet');
$this->userdetails->addDecorator(array('DtDdWrapper' => 'HtmlTag'), array('tag' => 'ul'));
$this->addDisplayGroup(array('submit'), 'submit');
$this->setLegend('Edit account details: ');
}