« Return to Thread: Zend_Form
Matthew Weier O'Phinney-3 wrote:It's documented and straightforward: You pass an array of error
code/message pairs to the 'messages' key in the params for the
validator:
$element = new Zend_Form_Element(array(
'validators' => array(
array('NotEmpty', false, array(
'messages' => array('isEmpty' => 'This is a custom message')
)),
)
);
The trick is remembering that 'messages' should be an *array*, and that
it should contain key/value pairs of validation class constants/mesages.
You can also simply use translation files, which are the easier method.
In that case, you provide translations for each validation error code
you want a custom message for, and attach the translator:
$form->setTranslator($translate);
You can use a translation object even if you only have one language; the
nice part is it future-proofs your site for additional languages. :-)
« Return to Thread: Zend_Form
| Free embeddable forum powered by Nabble | Forum Help |