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


PHP Zend_Validate_StringLength::setMessages方法代码示例

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


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

示例1: init

 /**
  * (non-PHPdoc)
  * @see Zend_Form::init()
  */
 public function init()
 {
     #$this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->setTranslator();
     $this->setAttrib('id', 'frmlogin');
     $txtEmail = $this->createElement('text', 'email')->setLabel("ACL_EMAIL")->setRequired(TRUE)->setAttrib('placeholder', 'user@example.com')->addFilters(array(new Zend_Filter_StringToLower(), new Zend_Filter_StringTrim()))->addValidator(new Zend_Validate_EmailAddress());
     #$txtEmail->setDescription('Complete the email');
     $this->addElement($txtEmail);
     $txtPassword = $this->createElement('password', 'password')->setLabel("ACL_PASSWORD")->setRequired(TRUE)->setAttrib('placeholder', '*******');
     #->setAttrib('size', 40);
     $length = new Zend_Validate_StringLength(6, 50);
     $length->setMessages(array('stringLengthTooShort' => sprintf($this->getTranslator()->translate('VALIDATE_PASSWORD_MIN'), 6), 'stringLengthTooLong' => sprintf($this->getTranslator()->translate('VALIDATE_PASSWORD_MAX'), 50)));
     $txtPassword->addValidator($length);
     $this->addElement($txtPassword);
     #$token = new Zend_Form_Element_Hash('token');
     $token = $this->createElement('hash', 'csrflogintoken');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(300);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_SUCCESS, 'type' => 'submit', 'buttonType' => 'success');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     #$btnSubmit = $this->createElement('submit', 'submit');
     $btnSubmit->setLabel('ACL_LOGIN');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
开发者ID:rogercastaneda,项目名称:owlsys,代码行数:34,代码来源:Login.php

示例2: testSetMessages

 /**
  * Ensures that we can set more than one message at a time,
  * by passing an array of key/message pairs.  Both messages
  * should be defined.
  *
  * @return void
  */
 public function testSetMessages()
 {
     $this->_validator->setMessages(array(Zend_Validate_StringLength::TOO_LONG => 'Your value is too long', Zend_Validate_StringLength::TOO_SHORT => 'Your value is too short'));
     $this->assertFalse($this->_validator->isValid('abcdefghij'));
     $messages = $this->_validator->getMessages();
     $this->assertEquals('Your value is too long', current($messages));
     $this->assertFalse($this->_validator->isValid('abc'));
     $messages = $this->_validator->getMessages();
     $this->assertEquals('Your value is too short', current($messages));
 }
开发者ID:omusico,项目名称:logica,代码行数:17,代码来源:MessageTest.php

示例3: init

 public function init()
 {
     $this->setMethod('post');
     $this->setAttribs(array('id' => 'login_form', 'class' => 'login_form'));
     // Username
     $label = 'Username';
     $validators = array();
     $validator = new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING);
     $validator->setMessages(array(Zend_Validate_NotEmpty::IS_EMPTY => "{$label} is required and must not be empty"));
     $validators[] = $validator;
     $min = 4;
     $max = 20;
     $validator = new Zend_Validate_StringLength(array('min' => $min, 'max' => $max));
     $validator->setMessages(array(Zend_Validate_StringLength::INVALID => "{$label} contains invalid type data", Zend_Validate_StringLength::TOO_SHORT => "{$label} must be at least {$min} characters", Zend_Validate_StringLength::TOO_LONG => "{$label} must be less than {$max} characters"));
     $validators[] = $validator;
     $element = new Zend_Form_Element_Text('username', array('required' => true, 'label' => "{$label}", 'filters' => array(new Zend_Filter_StringTrim()), 'validators' => $validators));
     $this->addElement($element);
     // Password
     $label = 'Password';
     $validators = array();
     $validator = new Zend_Validate_NotEmpty();
     $validator->setMessages(array(Zend_Validate_NotEmpty::IS_EMPTY => "{$label} is required and must not be empty"));
     $validators[] = $validator;
     $min = 4;
     $max = 20;
     $validator = new Zend_Validate_StringLength(array('min' => $min, 'max' => $max));
     $validator->setMessages(array(Zend_Validate_StringLength::INVALID => "{$label} contains invalid type data", Zend_Validate_StringLength::TOO_SHORT => "{$label} must be at least {$min} characters", Zend_Validate_StringLength::TOO_LONG => "{$label} must be less than {$max} characters"));
     $validators[] = $validator;
     $element = new Zend_Form_Element_Password('password', array('required' => true, 'label' => "{$label}", 'filters' => array(new Zend_Filter_StringTrim()), 'validators' => $validators));
     $this->addElement($element);
     // Submit Button
     $label = 'Login';
     $element = new Zend_Form_Element_Submit('submit_button', array('label' => "{$label}", 'ignore' => true, 'class' => 'proxy'));
     $decorators = array('ViewHelper', 'Errors');
     //$element->setDecorators($decorators);
     $this->addElement($element);
     // Hash
     //$element = new Zend_Form_Element_Hash('csrf_hash', array(
     //    'ignore' => true,
     //));
     //$decorators = array(
     //    'ViewHelper',
     //    array(array('input_wrapper' => 'HtmlTag'), array('tag' => 'div', 'style' => 'display: none;')),
     //);
     //$element->setDecorators($decorators);
     //$this->addElement($element);
 }
开发者ID:rocksolidwebdesign,项目名称:AweCMS,代码行数:47,代码来源:Login.php

示例4: validate

 function validate($txtInput)
 {
     $return_array = array();
     $validator = new Zend_Validate_StringLength(3, 250);
     //Validator messages
     $validator->setMessages(array(Zend_Validate_StringLength::TOO_SHORT => 'The string value, \' %value% \' is too short', Zend_Validate_StringLength::TOO_LONG => 'You entered \' %max% \' characters, which is over 250.'));
     // Looping through the text inputs
     foreach ($txtInput as $key => $txtIn) {
         if (!$validator->isValid($txtIn)) {
             $error = $validator->getMessages();
             foreach ($error as $e) {
                 $errorMessage = $key . ': ' . $e;
             }
             array_push($return_array, $errorMessage);
         }
     }
     return $return_array;
 }
开发者ID:jessicatsuji,项目名称:Portfolio_v1,代码行数:18,代码来源:ProjectsModel.php

示例5: _getValidatorStringLength

 /**
  * 
  * @param type $min
  * @param type $max
  * @param type $encoding
  * @param type $messages_prefixed
  * @return Zend_Validate_StringLength 
  */
 protected function _getValidatorStringLength($min = 0, $max = 255, $encoding = 'UTF-8', $messages_prefixed = "")
 {
     $messages_prefixed = strtoupper($messages_prefixed);
     $stringLength = new Zend_Validate_StringLength(array('min' => $min, 'max' => $max, 'encoding' => $encoding));
     $stringLength->setMessages(array(Zend_Validate_StringLength::INVALID => sprintf($this->_translate('ERROR_STRING_LENGTH_INVALID'), $this->_translate($messages_prefixed), $min, $max), Zend_Validate_StringLength::TOO_LONG => sprintf($this->_translate('ERROR_STRING_LENGTH_TOO_LONG'), $this->_translate($messages_prefixed), $max), Zend_Validate_StringLength::TOO_SHORT => sprintf($this->_translate('ERROR_STRING_LENGTH_TOO_SHORT'), $this->_translate($messages_prefixed), $min)));
     return $stringLength;
 }
开发者ID:BGCX067,项目名称:facebook-store-svn-to-git,代码行数:15,代码来源:Form.php

示例6: init

 public function init()
 {
     //$this->setAction('user/process');
     /*
             $decoradores = array(
                                   'ViewHelper',
                                   array('Errors', array('tag' => 'div', 'style' => 'color:red;')),
                                   array('HtmlTag', array('tag' => 'div', 'class' => 'formElement')),
                                   array('Label', array('tag' => 'div'))
                                 );
     
     
             
             // Case 1
             $nombre = new Zend_Form_Element_Text('nombre');
             
             $nombre->setLabel('Nombre :')
                     ->setDecorators($decoradores)
                     ->setRequired(true)
                     ->addFilter('StripTags')
                     ->addFilter('StringTrim')
                     ->addValidator('NotEmpty'); 
     
             $submit = new Zend_Form_Element_Submit( 'Enviar' );
             $submit->setAttrib('id', 'enviar');
     
             
     
             // Case 2
             //StripTags delete las etiquetas HTML
             //StringTrim quita todos los caracteres de espacio en blanco iniciales y finales
             $name = new Zend_Form_Element_Text('name');  
     	
             $name->setLabel('* Your Name:')
                  ->setRequired(true)
                  ->addFilter('StripTags')
                  ->addFilter('StringTrim')
                  ->setAttrib('size',50)
                  ->addValidator('stringLength', false, array(0, 300))
                  ->addValidator('NotEmpty',
                                  true,
                                  array('messages' => array(
                                                             Zend_Validate_NotEmpty::IS_EMPTY => 'Introducir su nombre es obligatorio.'
                                                            )
                                         
                                                         
                                       )
                                 )
                  ->setDecorators($decoradores);
             
             
             // Case 3
             
                 $this->addElement(
                                     'text', 
                                     'userBusinessName', 
                                     array(
                                             'label' => 'Nombre comercial (*)', 
                                             'required' => true, 
                                             'filters' => array('stringTrim'),
                                             'value' => '',
                                             
                                       )
                              );
             
                 $this->userBusinessName->setDecorators($decoradores);
                 //$this->userBusinessName->removeDecorator('Errors');
                 $this->userBusinessName->removeDecorator('HtmlTag');
                 $this->userBusinessName->removeDecorator('Label');
     
             
             
             $this->addElements (array( $nombre, $name, $submit ) );
     */
     // Formulario alta de usuario
     $decoradores = array('ViewHelper', array('Errors', array('tag' => 'div', 'style' => 'color:red;')), 'HtmlTag', 'Label');
     $validatorLenghtClave = new Zend_Validate_StringLength(6, 10);
     $validatorLenghtClave->setMessages(array(Zend_Validate_StringLength::TOO_SHORT => 'La clave es muy corta (min. %min%).', Zend_Validate_StringLength::TOO_LONG => 'La clave es muy large (max. %max%).'));
     $validatorLenghtCP = new Zend_Validate_StringLength(5, 5);
     $validatorLenghtCP->setMessages(array(Zend_Validate_StringLength::TOO_SHORT => 'El CP es de %min% digitos.', Zend_Validate_StringLength::TOO_LONG => 'El CP es de %max% digitos.'));
     // Tipo usuario
     /*
              $this->addElement(  'radio', 
                       'tipo', 
                       array(
                               'value' => '1',
                               'multiOptions' => array(
                                                           
                                                           0 => 'Particular',
                                                           1 => 'Profesional',
                                                      ),
                                           ));
     * 
     */
     // Correo electrónico
     $this->addElement('text', 'correoElectronico', array('label' => '', 'required' => true, 'filters' => array('stringTrim')));
     $this->correoElectronico->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'Introducir su correo electrónico.')));
     $this->correoElectronico->addValidator('EmailAddress', true, array('messages' => array(Zend_Validate_EmailAddress::INVALID => "El tipo especificado no es válido, el valor debe ser una cadena de texto", Zend_Validate_EmailAddress::INVALID_FORMAT => "'%value%' no es una dirección de correo electrónico válida en el formato local-part@hostname", Zend_Validate_EmailAddress::INVALID_HOSTNAME => "'%hostname%' no es un nombre de host válido para la dirección de correo electrónico '%value%'", Zend_Validate_EmailAddress::INVALID_MX_RECORD => "'%hostname%' no parece tener un registro MX válido para la dirección de correo electrónico '%value%'", Zend_Validate_EmailAddress::INVALID_SEGMENT => "'%hostname%' no esta en un segmento de red ruteable. La dirección de correo electrónico '%value%' no se debe poder resolver desde una red pública.", Zend_Validate_EmailAddress::DOT_ATOM => "'%localPart%' no es igual al formato dot-atom", Zend_Validate_EmailAddress::QUOTED_STRING => "'%localPart%' no es igual al formato quoted-string", Zend_Validate_EmailAddress::INVALID_LOCAL_PART => "'%localPart%' no es una parte local válida para la dirección de correo electrónico '%value%'", Zend_Validate_EmailAddress::LENGTH_EXCEEDED => "'%value%' excede la longitud permitida")));
     $this->correoElectronico->setDecorators($decoradores);
     $this->correoElectronico->setAttrib('class', 'form_input_contact');
//.........这里部分代码省略.........
开发者ID:eulernunez,项目名称:RentAFlat-Zend-1,代码行数:101,代码来源:UsuarioBack.php

示例7: addPasswordElement

 public function addPasswordElement($isInsert = true)
 {
     require_once 'Zend/Form/Element/Password.php';
     $element = new Zend_Form_Element_Password($this->getPasswordParam());
     $element->clearDecorators()->addDecorator('viewHelper')->setRenderPassword(true);
     #$password = $this->getPermiso()->getRequest()->getPost($this->getPasswordParam());
     $password = isset($_POST[$this->getPasswordParam()]) ? $_POST[$this->getPasswordParam()] : null;
     if ($isInsert || $password) {
         require_once 'Zend/Validate/NotEmpty.php';
         $notEmpty = new Zend_Validate_NotEmpty();
         $notEmpty->setMessages(array(Zend_Validate_NotEmpty::IS_EMPTY => $this->getTranslator()->translate('accountFormHintPasswordNotEmpty')));
         $element->addValidator($notEmpty)->setRequired(true);
         if ($password) {
             require_once 'Zend/Validate/StringLength.php';
             $stringLength = new Zend_Validate_StringLength($this->getPermiso()->getMinimalPasswordLength());
             $stringLength->setMessages(array(Zend_Validate_StringLength::TOO_SHORT => sprintf($this->getTranslator()->translate('accountFormHintPasswordStringLengthTooShort'), $this->getPermiso()->getMinimalPasswordLength())));
             $element->addValidator($stringLength);
         }
     }
     $this->addElement($element);
     return $this;
 }
开发者ID:sitengine,项目名称:sitengine,代码行数:22,代码来源:Form.php


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