Zend_Form -> Nicely change setRequired() validate message

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

    Try this..

    $ausPostcode = new Zend_Form_Element_Text('aus_postcode'); $ausPostcode->setLabel('Australian Postcode')
    ->setRequired(true)
    ->addValidator('StringLength', false, array(4, 4))
    ->addValidator(new Zend_Validate_Digits(), false)
    ->getValidator('digits')->setMessage('Postcode can only contain digits');
    

    This sets the custom error message only for the Digits validator.

提交回复
热议问题