Hi all,
I'm using Zend_Validate
to validate some form input (Zend Framework version is 1.8.2). For some reason, using the Zend_Filter_Input
interface as described here does not work:
$data = $_POST;
$filters = array('*' => array('StringTrim'));
$validators = array('driverName' => array('NotEmpty','messages' => 'This should override the default message but does not!'));
$inputFilter = new Zend_Filter_Input($filters,$validators,$data);
$messages = $inputFilter->getMessages();
debug($messages); //show me the variable contents
Output from debug($messages)
:
Array
(
[driverName] => Array
(
[isEmpty] => You must give a non-empty value for field 'driverName'
)
)
No matter what I do, I cannot override that message. If I use the validator directly, i.e.:
$notEmpty = new Zend_Validate_NotEmpty();
$notEmpty->setMessage('This WILL override the default validation error message');
if (!$notEmpty->isValid($_POST['driverName'])) {
$messages = $notEmpty->getMessages();
debug($messages);
}
Output from debug($messages)
:
Array
(
[isEmpty] => Please enter your name
)
Bottom line. I can get validators to work, but without the benefits of the Zend_Filter_Input
interface method of validation I might as well write my own validation class!
Does anyone have a clue as to why this is happening, and how to fix it?
Could it be a bug?