问题
I have got a ValidationFilter like Db_NoRecordExists in Zend 1. But in some cases it's okay that there is already a record with the same value - for example when i want to update some data. Maybe the username would be still the same after updating. But then my ValidationFilter gives an error. Now i could use something like "exclude ID XYZ". But how can i pass that IDs to the validationfilter?
Thank You!
回答1:
Use the setValidationGroup() method to tell your form which fields it should care about.
eg if your form had 3 fields named username, email and country, and you don't need to validate username because it's not going to be changed, you can do the following in your controller (assuming $form is an instance of your form)
$form->setValidationGroup(array(
'email',
'country',
));
来源:https://stackoverflow.com/questions/15300105/how-can-i-pass-some-data-to-a-validationfilter-zend-2