I know its bad discussion etiquette, but does anyone have a possible
solution to my problem below? I have tried it with 1.5 RC 1 and still
have the same issue.
fugazied wrote:
I am having some issues with the custom messaging and Zend Input Filter.
Probably something obvious I am missing, but a search couldn't help me find
a solution. Some Code:
// ------------------------------------
$validators = array(
'email' => array('EmailAddress', 'presence'=>'required',
,'allowEmpty'=>false ),
'month' => array('Digits', 'presence'=>'required', ,'allowEmpty'=>false,
array('Between', 1, 10) )
);
$options = array(
'missingMessage' => "Field '%field%' is required",
'notEmptyMessage' => "A non-empty value is required for field '%field%'"
);
$input = new Zend_Filter_Input(null, $validators);
$input->setOptions($options);
$input->setData($_POST);
if ($input->hasInvalid() || $input->hasMissing()) {
$invalidFields = $input->getInvalid();
Zend_Debug::dump($invalidFields);
/*
Produces -
array(2) {
["email"] => array(1) {
["emailAddressInvalid"] => string(71) "'' is not a valid email address
in the basic format [EMAIL PROTECTED]"
}
["month"] => array(2) {
["stringEmpty"] => string(21) "'' is an empty string"
["notBetween"] => string(43) "'' is not between '1' and '10',
inclusively"
}
}
*/
}
// ------------------------------------
I was under the impression that my custom messages would replace the " '' is
an empty string ".
And to avoid the other error messages appearing, display empty ' ' field
values I need to chain the validators correct?
Thanks!