Zend_Form -> Nicely change setRequired() validate message

前端 未结 10 1304
死守一世寂寞
死守一世寂寞 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条回答
  •  醉话见心
    2021-01-31 10:01

    Try

    ->addValidator('Digits', false);
    

    or

    ->addValidator('Digits');
    

    You assume that to check Digits it has to have a string length anyway.

    Also, I like to do some custom error messages like this:

    $firstName->getValidator('NotEmpty')->setMessage('Please enter your first name');
    

    This allows you to "get" the validator and then "set" properties of it.

提交回复
热议问题