Hi
I have a form with a text element and that I want to be validated as a date.
$date = new Zend_Form_Element_Text('Date');
$date->setLabel('Date')
->addValidator(
'Date',
true,
array(
'messages' => array(
'dateInvalidDate' => 'Opsss! Invalid date!',
'dateNotYYYY-MM-DD' => 'Opsss! Should enter a date!'
)
)
)
->addValidator('NotEmpty', true, array('messages' => array('isEmpty' =>
'It can't be empty!')))
->setRequired(true);
If I leave date empty, $form->getMessages() says
[Date] => Array
(
[dateNotYYYY-MM-DD] => Opsss! Should enter a date!
)
If I remove the NotEmpty validator it shows:
[Date] => Array
(
[isEmpty] => Value is required and can't be empty // not the message I
expect: It can't be empty
)
But if I add 'isEmpty' to the messages array in the first validator It
throws an exception.
Fatal error: Uncaught exception 'Zend_Validate_Exception'
with message 'No message template exists for key 'isEmpty''
in C:\wwwroot\lib\php\ZendFramework\library\Zend\Validate\Abstract.php:149
...
What could be happening here?
Cheers
holo