Zend_Form -> Nicely change setRequired() validate message

前端 未结 10 1305
死守一世寂寞
死守一世寂寞 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:15

    But try this:

    $firstName->setRequired(true)
              ->addValidator('NotEmpty', false, array('messages' => 'bar'))
              ->addValidator('Alpha', false, array('messages'=>'Must contain only letters'));
    

    If left empty and submitted, itll give two messages bar & '' is an empty string. Its that second message thats coming from setRequired(true) thats the problem

提交回复
热议问题