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


PHP Zend_Form_Element::setRequired方法代码示例

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


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

示例1: addDefaultValidators

 private function addDefaultValidators(Zend_Form_Element $element, $meta)
 {
     if (!$meta['NULLABLE'] && $meta['PRIMARY'] != true) {
         $element->setRequired(true);
         $element->setAllowEmpty(false);
     }
 }
开发者ID:roed,项目名称:zend-mvc-extend,代码行数:7,代码来源:Abstract.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: testRenderAppendsRequiredClassToClassProvidedInRequiredElement

 public function testRenderAppendsRequiredClassToClassProvidedInRequiredElement()
 {
     $element = new Zend_Form_Element('foo');
     $element->setRequired(true)->setView($this->getView())->setLabel('My Label')->setAttrib('class', 'bazbat');
     $this->decorator->setElement($element);
     $content = 'test content';
     $test = $this->decorator->render($content);
     $this->assertRegexp('/<label[^>]*?class="[^"]*required/', $test, $test);
     $this->assertNotRegexp('/<label[^>]*?class="[^"]*bazbat/', $test, $test);
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:10,代码来源:LabelTest.php

示例5: testRenderAddsRequiredClassForNonRequiredElements

    public function testRenderAddsRequiredClassForNonRequiredElements()
    {
        $element = new Zend_Form_Element('foo');
        $element->setRequired(true)
                ->setView($this->getView())
                ->setLabel('My Label');
        $this->decorator->setElement($element);
        $content = 'test content';
        $test = $this->decorator->render($content);
        $this->assertRegexp('/<label[^>]*?class="[^"]*required/', $test, $test);

        $element->class = "bar";
        $this->decorator->setOption('class', 'foo');
        $test = $this->decorator->render($content);
        $this->assertNotContains('bar', $test);
        $this->assertRegexp('/<label[^>]*?class="[^"]*foo/', $test, $test);
        $this->assertRegexp('/<label[^>]*?class="[^"]*required/', $test, $test);
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:18,代码来源:LabelTest.php

示例6: setRequired

 /**
  * Define o elemento como obrigatório e acrescenta as classes de CSS required 
  * @param bool $flag
  * @author Jhonatan Morais <jhonatanvinicius@gmail.com>
  */
 public function setRequired($flag = true)
 {
     parent::setRequired($flag);
     if ((bool) $flag) {
         $this->addValidator("NotEmpty");
     } else {
         $this->removeValidator("NotEmpty");
     }
     return $this;
 }
开发者ID:getJv,项目名称:ModuleTeste,代码行数:15,代码来源:Element.php


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