本文整理汇总了PHP中Zend_Validate_NotEmpty::setMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_NotEmpty::setMessages方法的具体用法?PHP Zend_Validate_NotEmpty::setMessages怎么用?PHP Zend_Validate_NotEmpty::setMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Validate_NotEmpty
的用法示例。
在下文中一共展示了Zend_Validate_NotEmpty::setMessages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: addTimezoneElement
public function addTimezoneElement($default = '')
{
require_once 'Zend/Validate/NotEmpty.php';
$notEmpty = new Zend_Validate_NotEmpty();
$notEmpty->setMessages(array(Zend_Validate_NotEmpty::IS_EMPTY => $this->getTranslator()->translate('accountFormHintTimezoneNotEmpty')));
require_once 'Zend/Form/Element/Select.php';
$element = new Zend_Form_Element_Select($this->getTimezoneParam());
$element->clearDecorators()->addDecorator('viewHelper')->setValue($default)->setDisableTranslator(true);
// set options directly for massively enhanced performance
$element->options = $this->getPermiso()->getEnv()->getTimezones();
$this->addElement($element);
return $this;
}