Reputation: 4118
What is the right way to assign a few validators to the same data field when using Zend_Input_Filter.
E.g. my validators array is this and I need to validations on Field2:
$validators = array(
'Field1' => array(
'NotEmpty',
'messages' => 'Field1 must be filled'
),
'Feild2' => array(
'NotEmpty',
'messages' => 'Field2 must be selected'
),
'Field2' => array(
'Digits',
'messages' => 'Field2 must be numeric'
),
);
Then I call
$input = new Zend_Filter_Input(null, $validators, $data);
But I guess I can't use array key 'Field2' twise. Then how to I bind to validators to just 1 field?
P.S. Well, I know the hard way is to stuff all field validators into one class, but I hope there is and easy ZF way, the configuration way.
Upvotes: 1
Views: 112
Reputation: 342765
$validators = array(
'Field1' => array(
'NotEmpty', 'Digits', new Zend_Validate_Blahblah(),
'messages' => array('Field1 must be filled',
'Field1 must be numeric',
'Field1 must be a blahblah')
),
...
);
Give this a read:
http://framework.zend.com/manual/en/zend.filter.input.html
Upvotes: 1