本文整理汇总了PHP中Zend_Form_Element_Password::addValidators方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Password::addValidators方法的具体用法?PHP Zend_Form_Element_Password::addValidators怎么用?PHP Zend_Form_Element_Password::addValidators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element_Password
的用法示例。
在下文中一共展示了Zend_Form_Element_Password::addValidators方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
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 email field
$input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email'));
$validator = new Zend_Validate_EmailAddress();
$validator->setOptions(array('domain' => false));
$input->addValidators(array($validator, new Zend_Validate_NotEmpty()));
$input->addDecorator($decoratorField);
$elements[] = $input;
// Add password field
$input = new Zend_Form_Element_Password('password', array('required' => true, 'label' => 'Password:', 'id' => 'password', 'class' => 'form-control', 'placeholder' => 'Your password..'));
$input->addValidators(array(new Zend_Validate_NotEmpty()));
$input->addDecorator($decoratorField);
$elements[] = $input;
// Add checkbox field
$input = new Zend_Form_Element_Checkbox('rememberMe', array('label' => 'Remember me', 'id' => 'rememberMe', 'class' => 'checkbox', 'type' => 'checkbox'));
$decoratorCheckBox = new My_Decorator_CheckBox();
$input->addDecorator($decoratorCheckBox);
$elements[] = $input;
$input = new Zend_Form_Element('resetpass', array('label' => 'Reset your password', 'id' => 'resetpass', 'class' => 'form-control', 'value' => 'resetpass'));
$input->addDecorator(new My_Decorator_AnchoraForm());
$elements[] = $input;
//Add Submit button
$input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'Login'));
$input->addDecorator($decoratorField);
$elements[] = $input;
$this->addElements($elements);
$this->addDisplayGroup(array('email', 'password', 'resetpass', 'rememberMe', 'submit'), 'displgrp', array('decorators' => array('FormElements', 'Fieldset')));
}
示例2: init
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')));
}
示例3: init
public function init()
{
$this->addDecorators(array("ViewHelper"), array("Errors"));
$new_password = new Zend_Form_Element_Password("new_password");
$new_password->setLabel("New Password");
$new_password->setRequired(true);
$new_password->addValidators(array(array("validator" => "NotEmpty", "breakChainOnFailure" => true)), array("validator" => "alnum", "options" => array("allowWhiteSpace" => false)), array("validator" => "stringLength", "options" => array(6, 30)));
$confirm_password = new Zend_Form_Element_Password("confirm_password");
$confirm_password->setLabel("Confirm New Password");
$confirm_password->setRequired(true);
$confirm_password->addValidators(array(array("validator" => "NotEmpty", "breakChainOnFailure" => true)), array("validator" => "alnum", "options" => array("allowWhiteSpace" => false)), array("validator" => "stringLength", "options" => array(6, 30)));
$owner_id = new Zend_Form_Element_Hidden("owner_id");
$owner_id->setRequired(true);
$this->addElements(array($new_password, $confirm_password, $owner_id));
}
示例4: init
public function init()
{
$this->addDecorators(array("ViewHelper"), array("Errors"));
$username = new Zend_Form_Element_Text("username");
$username->setRequired(true);
$username->setLabel("Username");
$username->addValidators(array(array("validator" => "NotEmpty")), array("validator" => "alpha", "options" => array("allowWhiteSpace" => false)), array("validator" => "stringLength", "options" => array(6, 30)));
$password = new Zend_Form_Element_Password("password");
$password->setRequired(true);
$password->setLabel("Password");
$password->addValidators(array(array("validator" => "NotEmpty")), array("validator" => "alnum", "options" => array("allowWhiteSpace" => false)), array("validator" => "stringLength", "options" => array(6, 30)));
$rememberMe = new Zend_Form_Element_Checkbox("remember_me");
$this->setMethod(Zend_Form::METHOD_POST);
$this->addElements(array($username, $password, $rememberMe));
}
示例5: __construct
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('changepassword_form');
$password = new Zend_Form_Element_Password('password');
$password->setLabel(_r('New Password'))->setRequired(true)->addFilter('StripTags');
$not_empty = new Zend_Validate_NotEmpty();
$password->addValidators(array($not_empty));
$passwordConfirm = new Zend_Form_Element_Password('passwordconf');
$passwordConfirm->setLabel(_r('Confirm Password'))->setRequired(true)->addFilter('StripTags');
$passwordConfirm->addValidators(array($not_empty));
$passwordConfirm->addValidator('Identical', false, array('token' => 'password'));
$submit = new Zend_Form_Element_Image('btn_submit');
$submit->setImage('/images/buttons/small/save-changes.png');
$this->addElements(array($password, $passwordConfirm, $submit));
}
示例6: init
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_Field();
$elements = array();
// Add name field
$input = new Zend_Form_Element_Text('host', array('required' => true, 'label' => 'SMTP Host:', 'id' => 'host', 'placeholder' => 'Type something..', 'class' => 'form-control', 'value' => 'smtp.gmail.com'));
$input->addValidators(array(new Zend_Validate_NotEmpty()));
$input->addDecorator($decoratorField);
$elements[] = $input;
// Add category field
$select = new Zend_Form_Element_Select('stype', array('required' => true, 'label' => 'Security:', 'id' => 'stype', 'class' => 'form-control'));
$select->addMultiOption('TLS', 'TLS');
$select->addMultiOption('SSH', 'SSH');
$select->setValue('TLS');
$select->addDecorator($decoratorField);
$elements[] = $select;
// Add Price field
$input = new Zend_Form_Element_Text('port', array('required' => true, 'label' => 'Port:', 'id' => 'port', 'placeholder' => 'Type something..', 'class' => 'form-control', 'min' => 0, 'step' => '1', 'type' => 'number', 'value' => '587'));
$min = new Zend_Validate_GreaterThan(0);
$input->addValidators(array(new Zend_Validate_Digits(), $min, new Zend_Validate_NotEmpty()));
$input->addDecorator($decoratorField);
$elements[] = $input;
$input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'SMTP Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email', 'value' => 'testarnia@gmail.com'));
$input->addValidators(array(new Zend_Validate_EmailAddress(), new Zend_Validate_NotEmpty()));
$input->addDecorator($decoratorField);
$elements[] = $input;
// Add category field
$input = new Zend_Form_Element_Password('password1', array('required' => true, 'label' => 'Password:', 'id' => 'password1', 'class' => 'form-control', 'placeholder' => 'Your SMTP password..'));
$input->addValidators(array(new Zend_Validate_NotEmpty()));
$input->addDecorator($decoratorField);
$elements[] = $input;
// Add category field
$input = new Zend_Form_Element_Password('password2', array('required' => true, 'label' => 'Password Again:', 'id' => 'password2', 'class' => 'form-control', 'placeholder' => 'Your SMTP password again..', 'validators' => array(array('identical', false, array('token' => 'password1')))));
$input->addDecorator($decoratorField);
$elements[] = $input;
//Add Submit button
$input = new Zend_Form_Element_Submit('submit', array('Label' => ' ', 'class' => 'btn btn-info', 'value' => 'Add New Configuration'));
$input->addDecorator($decoratorField);
$elements[] = $input;
$this->addElements($elements);
$this->addDisplayGroup(array('host', 'stype', 'port', 'email', 'password1', 'password2', 'submit'), 'displgrp', array('legend' => 'Add Products', 'decorators' => array('FormElements', 'Fieldset')));
return $this;
}
示例7: __construct
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('serverSettings');
$server_name = new Zend_Form_Element_Text('name');
$server_name->setLabel(_r('Name'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
$not_empty = new Zend_Validate_NotEmpty();
$not_empty->setMessage(_r('Please enter the Server Name'));
$server_name->addValidators(array($not_empty));
$hostname = new Zend_Form_Element_Text('hostname');
$hostname->setLabel(_r('Hostname'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
$not_empty = new Zend_Validate_NotEmpty();
$not_empty->setMessage(_r('Please enter the Hostname'));
$hostname->addValidators(array($not_empty));
$ct_map = new GD_Model_ConnectionTypesMapper();
$connection_types = $ct_map->fetchAll();
$connection_type_id = new Zend_Form_Element_Select('connectionTypeId');
$connection_type_id->setLabel(_r('Connection Type'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
$not_empty = new Zend_Validate_NotEmpty();
$not_empty->setMessage(_r('Please choose a Connection Type'));
$connection_type_id->addValidators(array($not_empty));
foreach ($connection_types as $connection_type) {
$connection_type_id->addMultiOption($connection_type->getId(), $connection_type->getName());
}
$port = new Zend_Form_Element_Text('port');
$port->setLabel(_r('Port'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim');
$not_empty = new Zend_Validate_NotEmpty();
$not_empty->setMessage(_r('Please enter the Port Number'));
$port->addValidators(array($not_empty));
$username = new Zend_Form_Element_Text('username');
$username->setLabel(_r('Username'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('autocomplete', 'off');
$not_empty = new Zend_Validate_NotEmpty();
$not_empty->setMessage(_r('Please enter the Username'));
$username->addValidators(array($not_empty));
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('autocomplete', 'off')->setAttrib('renderPassword', true);
$not_empty = new Zend_Validate_NotEmpty();
$not_empty->setMessage(_r('Please enter the Password'));
$password->addValidators(array($not_empty));
$report_path = new Zend_Form_Element_Text('remotePath');
$report_path->setLabel(_r('Remote Path'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim');
$submit = new Zend_Form_Element_Image('btn_submit');
$submit->setImage('/images/buttons/small/save-changes.png');
$this->addElements(array($server_name, $hostname, $connection_type_id, $port, $username, $password, $report_path, $submit));
}
示例8: __construct
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('login_form')->setAction('/auth/login')->setMethod('post');
$username = new Zend_Form_Element_Text('username');
$username->setLabel(_r('Username'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
$not_empty = new Zend_Validate_NotEmpty();
$not_empty->setMessage(_r('Please enter your User Name'));
$username->addValidators(array($not_empty));
$password = new Zend_Form_Element_Password('password');
$password->setLabel(_r('Password'))->setRequired(true)->addFilter('StripTags');
$not_empty = new Zend_Validate_NotEmpty();
$not_empty->setMessage(_r('Please enter your Password'));
$password->addValidators(array($not_empty));
$submit = new Zend_Form_Element_Image('btn_submit');
$submit->setImage('/images/buttons/small/login.png');
$this->addElements(array($username, $password, $submit));
}
示例9: init
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 name field
$input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email'));
$input->addValidators(array(new Zend_Validate_EmailAddress(), new Zend_Validate_NotEmpty()));
$input->addDecorator($decoratorField);
$elements[] = $input;
// Add category field
$input = new Zend_Form_Element_Password('password1', array('required' => true, 'label' => 'Password:', 'id' => 'password1', '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 category field
$input = new Zend_Form_Element_Password('password2', array('required' => true, 'label' => 'Password Again:', 'id' => 'password2', 'class' => 'form-control', 'placeholder' => 'Your password again..', 'validators' => array(array('identical', false, array('token' => 'password1')))));
$input->addDecorator($decoratorField);
$elements[] = $input;
// Add code field
$input = new Zend_Form_Element_Text('currency_code', array('required' => true, 'label' => 'Currency Code:', 'id' => 'currency_code', 'placeholder' => 'Example USD', 'class' => 'form-control', 'list' => 'currencies', 'autocomplete' => 'off'));
$validator = new Zend_Validate_StringLength(array('max' => 3));
$input->addValidators(array($validator, new Zend_Validate_NotEmpty()));
$currencyMapper = new Application_Model_CurrencyMapper();
$currencies = $currencyMapper->fetchAllActive();
$decoratorCurrency = new My_Decorator_CurrencyAutocomplete(null, $currencies);
$input->addDecorator($decoratorCurrency);
$elements[] = $input;
//Add Submit button
$input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'SignUp'));
$input->addDecorator($decoratorField);
$elements[] = $input;
$this->addElements($elements);
$this->addDisplayGroup(array('email', 'password1', 'password2', 'currency_code', 'submit'), 'displgrp', array('decorators' => array('FormElements')));
}
示例10: __construct
public function __construct($options = null)
{
parent::__construct($options);
$translate = Zend_Registry::get('Zend_Translate');
$this->removeDecorator('DtDdWrapper');
$this->setName('register_form');
$this->setAttrib('id', 'register_form');
$this->addElementPrefixPath('Oibs_Decorators', 'Oibs/Decorators/', 'decorator');
$this->addElementPrefixPath('Oibs_Validators', 'OIBS/Validators/', 'validate');
$city = new Zend_Form_Element_Text('city');
$city->setLabel($translate->_("account-register-city"))->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty'))), array('Regex', true, array('/^[\\p{L}0-9.\\- ]*$/'))))->setDecorators(array('RegistrationDecorator'));
$mailvalid = new Zend_Validate_EmailAddress();
$mailvalid->setMessage('email-invalid', Zend_Validate_EmailAddress::INVALID);
$mailvalid->setMessage('email-invalid-hostname', Zend_Validate_EmailAddress::INVALID_HOSTNAME);
$mailvalid->setMessage('email-invalid-mx-record', Zend_Validate_EmailAddress::INVALID_MX_RECORD);
$mailvalid->setMessage('email-dot-atom', Zend_Validate_EmailAddress::DOT_ATOM);
$mailvalid->setMessage('email-quoted-string', Zend_Validate_EmailAddress::QUOTED_STRING);
$mailvalid->setMessage('email-invalid-local-part', Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
$mailvalid->setMessage('email-length-exceeded', Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
$mailvalid->hostnameValidator->setMessage('hostname-invalid-hostname', Zend_Validate_Hostname::INVALID_HOSTNAME);
$mailvalid->hostnameValidator->setMessage('hostname-local-name-not-allowed', Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
$mailvalid->hostnameValidator->setMessage('hostname-unknown-tld', Zend_Validate_Hostname::UNKNOWN_TLD);
$mailvalid->hostnameValidator->setMessage('hostname-invalid-local-name', Zend_Validate_Hostname::INVALID_LOCAL_NAME);
$mailvalid->hostnameValidator->setMessage('hostname-undecipherable-tld', Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
$email = new Zend_Form_Element_Text('email');
$email->setLabel($translate->_("account-register-email"))->setRequired(true)->addFilter('StringtoLower')->addValidators(array($mailvalid))->addErrorMessage('email-invalid')->setDecorators(array('RegistrationDecorator'));
$e_options = array("" => "account-select", "private_sector" => "account-register_private_sector", "public_sector" => "account-register_public_sector", "education_sector" => "account-register_education_sector", "student" => "account-register_student", "pentioner" => "account-register_pentioner", "other" => "account-register_other");
$employment = new Zend_Form_Element_Select('employment');
$employment->setLabel($translate->_("account-register-employment"))->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty')))))->addMultiOptions($e_options)->setDecorators(array('RegistrationDecorator'));
$username = new Zend_Form_Element_Text('username');
$username->setLabel($translate->_("account-register-username"))->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty'))), array('StringLength', false, array(4, 16, 'messages' => array('stringLengthTooShort' => 'field-too-short', 'stringLengthTooLong' => 'field-too-long'))), new Oibs_Validators_UsernameExists('username'), new Oibs_Validators_Username('username')))->setDecorators(array('RegistrationDecorator'));
$password = new Zend_Form_Element_Password('password');
$password->setLabel($translate->_("account-register-password"));
$password->setRequired(true);
$password->addValidators(array(new Oibs_Validators_RepeatValidator('confirm_password'), array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty'))), array('StringLength', false, array(4, 16, 'messages' => array('stringLengthTooShort' => 'field-too-short', 'stringLengthTooLong' => 'field-too-long')))));
$password->setDecorators(array('RegistrationDecorator'));
$confirm_password = new Zend_Form_Element_Password('confirm_password');
$confirm_password->setLabel($translate->_("account-register-password_confirm"));
$confirm_password->setRequired(true);
$confirm_password->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty')));
$confirm_password->addValidator('StringLength', false, array(4, 16, 'messages' => array('stringLengthTooShort' => 'field-too-short', 'stringLengthTooLong' => 'field-too-long')));
$confirm_password->setDecorators(array('RegistrationDecorator'));
$captcha = new Zend_Form_Element('captcha');
$captcha->setDecorators(array('CaptchaDecorator'));
$captcha_text = new Zend_Form_Element_Text('captcha_text');
$captcha_text->setLabel($translate->_("account-register-enter_text"))->addValidators(array(new Oibs_Validators_CaptchaValidator(), array('NotEmpty', true, array('messages' => array('isEmpty' => 'field-empty')))))->setRequired(true)->setDecorators(array('RegistrationDecorator'));
$text = sprintf($translate->_("account-register-terms_and_privacy"), "terms", "privacy");
// this solution sucks. the codes are in the translate block directly.
// anyone think of a fix to move codes out of there?
// - Joel
$terms = new Zend_Form_Element_Checkbox('terms');
$terms->setDescription($text)->setLabel("account-register-terms")->setChecked(false)->setRequired(true)->addValidators(array(new Oibs_Validators_CheckboxValidator()))->setDecorators(array('RegistrationTermsDecorator'));
// checkboxes always have a value of 1or0, this is a "feature" in ZF
// custom validator is a workaround
// -Joel
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel($translate->_("account-register-submit"))->removeDecorator('DtDdWrapper')->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'registration_submit_div'))))->setAttrib('class', 'registration_form_submit_' . $translate->getLocale());
$this->addElements(array($username, $password, $confirm_password, $city, $email, $employment, $captcha, $captcha_text, $terms, $submit));
/*$this->addDisplayGroup(array('username', 'password', 'confirm_password'), 'account_information');
$this->account_information->setLegend('register-account-information');
$this->account_information->removeDecorator('DtDdWrapper');
$this->addDisplayGroup(array('city', 'email', 'employment'), 'personal_information');
$this->personal_information->removeDecorator('DtDdWrapper');
$this->personal_information->setLegend('register-personal-information');
$this->addDisplayGroup(array('captcha', 'captcha_text', 'terms', 'submit'), 'confirmations');
$this->confirmations->removeDecorator('DtDdWrapper');
$this->confirmations->setLegend('register-confirmations');*/
}