当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Form_Element::addValidator方法代码示例

本文整理汇总了PHP中Zend_Form_Element::addValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element::addValidator方法的具体用法?PHP Zend_Form_Element::addValidator怎么用?PHP Zend_Form_Element::addValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Form_Element的用法示例。


在下文中一共展示了Zend_Form_Element::addValidator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setupElement

 public function setupElement()
 {
     $element = new Zend_Form_Element('foo');
     $element->addValidator('Alnum')->addValidator('Alpha')->setView($this->getView());
     $element->isValid('abc-123');
     $this->element = $element;
     $this->decorator->setElement($element);
 }
开发者ID:lortnus,项目名称:zf1,代码行数:8,代码来源:ErrorsTest.php

示例2:

 /**
  * 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));
 }
开发者ID:kakarot1991,项目名称:paid-to-click-cms,代码行数:45,代码来源:Registration.php

示例3:

 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));
 }
开发者ID:kakarot1991,项目名称:paid-to-click-cms,代码行数:21,代码来源:Login.php

示例4: testValidatorsGivenArrayKeysOnValidation

 /**
  * Check array notation for validators
  */
 public function testValidatorsGivenArrayKeysOnValidation()
 {
     $username = new Zend_Form_Element('username');
     $username->addValidator('stringLength', true, array('min' => 5, 'max' => 20, 'ignore' => 'something'));
     $form = new Zend_Form(array('elements' => array($username)));
     $this->assertTrue($form->isValid(array('username' => 'abcde')));
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:10,代码来源:ElementTest.php

示例5: testGetValidSubFormValues

 /**
  * @group ZF-8494
  */
 public function testGetValidSubFormValues()
 {
     $data = array('sub' => array('valid' => 1234, 'invalid' => 'invalid', 'noElement' => 'noElement'));
     require_once "Zend/Validate/Int.php";
     $subForm = new Zend_Form_SubForm();
     $validElement = new Zend_Form_Element("valid");
     $validElement->addValidator(new Zend_Validate_Int());
     $subForm->addElement($validElement);
     $invalidElement = new Zend_Form_Element('invalid');
     $invalidElement->addValidator(new Zend_Validate_Int());
     $subForm->addElement($invalidElement);
     $this->form->addSubForm($subForm, 'sub');
     $this->assertEquals(array('sub' => array('valid' => 1234)), $this->form->getValidValues($data));
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:17,代码来源:FormTest.php

示例6: createTaskElement

 /**
  * Will set up a task-element and decorators
  * @param string $id
  * @param array $values
  * @param array $attribs
  * @return Zend_Form_Element
  */
 protected function createTaskElement($id, $values, $isNew = false)
 {
     $elm = new Zend_Form_Element((string) $id);
     $elm->clearDecorators();
     $elm->addDecorator(new My_Decorator_TaskElement());
     $elm->addDecorator('Errors', array('placement' => 'prepend'));
     // add configured validator
     $validator = new My_Validator_TaskElement();
     $validator->setIsNew($isNew);
     $elm->addValidator($validator);
     return $elm;
 }
开发者ID:TBeijen,项目名称:Zend_Form_Dynamic,代码行数:19,代码来源:My_SubForm_TaskDay.php

示例7: testBreakChainOnFailureFlagsForExistingValidatorsRemainSetWhenNotEmptyValidatorAutoInserted

    /**
     * @see ZF-2862
     */
    public function testBreakChainOnFailureFlagsForExistingValidatorsRemainSetWhenNotEmptyValidatorAutoInserted()
    {
        $this->_checkZf2794();

        $username = new Zend_Form_Element('username');
        $username->addValidator('stringLength', true, array(5, 20))
                 ->addValidator('regex', true, array('/^[a-zA-Z0-9_]*$/'))
                 ->addFilter('StringToLower')
                 ->setRequired(true);
        $form = new Zend_Form(array('elements' => array($username)));
        $form->isValid(array('username' => '#'));

        $validator = $username->getValidator('stringLength');
        $this->assertTrue($validator->zfBreakChainOnFailure);
        $validator = $username->getValidator('regex');
        $this->assertTrue($validator->zfBreakChainOnFailure);
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:20,代码来源:ElementTest.php

示例8: testValidatorByUsingStringNotation

 /**
  * @see ZF-6822
  */
 public function testValidatorByUsingStringNotation()
 {
     $this->_checkZf2794();
     $username = new Zend_Form_Element('username');
     $username->addValidator('stringLength', true, array(5, 20))->addValidator('regex', true, '/^[a-zA-Z0-9_]*$/')->addFilter('StringToLower')->setRequired(true);
     $form = new Zend_Form(array('elements' => array($username)));
     $form->isValid(array('username' => '#'));
     $validator = $username->getValidator('stringLength');
     $this->assertTrue($validator->zfBreakChainOnFailure);
     $validator = $username->getValidator('regex');
     $this->assertTrue($validator->zfBreakChainOnFailure);
 }
开发者ID:netvlies,项目名称:zf,代码行数:15,代码来源:ElementTest.php

示例9: applyCustomMessages

 /**
  * Fügt angepasste Nachrichten für Validierungen hinzu.
  * @param Zend_Form_Element $element
  */
 protected function applyCustomMessages($element)
 {
     if ($element->isRequired()) {
         // wenn Validator 'notEmpty' bereits gesetzt ist; nicht modifizieren
         if (!$element->getValidator('notEmpty') && $element->autoInsertNotEmptyValidator()) {
             $notEmptyValidator = new Zend_Validate_NotEmpty();
             $notEmptyValidator->setMessage('admin_validate_error_notempty');
             $element->addValidator($notEmptyValidator);
         }
     }
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:15,代码来源:Abstract.php


注:本文中的Zend_Form_Element::addValidator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。