Zend_Form -> Nicely change setRequired() validate message

前端 未结 10 1332
死守一世寂寞
死守一世寂寞 2021-01-31 09:25

Say I create a text element like this:

$firstName = new Zend_Form_Element_Text(\'firstName\');
$firstName->setRequired(true);

Whats

10条回答
  •  猫巷女王i
    2021-01-31 10:14

    An easier way to set this "site-wide" would be to possibly do the following in a bootstrap or maybe a base zend_controller:

     'Value must be entered',
                            Zend_Validate_Regex::NOT_MATCH => 'Invalid value entered',
                            Zend_Validate_StringLength::TOO_SHORT => 'Value cannot be less than %min% characters',
                            Zend_Validate_StringLength::TOO_LONG => 'Value cannot be longer than %max% characters',
                            Zend_Validate_EmailAddress::INVALID => 'Invalid e-mail address'
                        );
        $translator = new Zend_Translate('array', $translateValidators);
        Zend_Validate_Abstract::setDefaultTranslator($translator);
    ?>
    

提交回复
热议问题