How to transfer some data to ValidationFilter? [Zend 2]

I have a ValidationFilter, like Db_NoRecordExists in Zend 1. But in some cases it’s good that there is already a record with the same value - for example, when I want to update some data. Perhaps after updating the username will remain the same. But then my ValidationFilter gives an error. Now I can use something like "exclude ID XYZ". But how can I pass these identifiers to a validationfilter file?

Thanks!

0
source share
1 answer

Use the setValidationGroup() method to tell your form which fields it should care about.

For example, if your form had 3 fields with username , email and country , and you do not need to check username because it will not be changed, you can do the following in your controller (assuming that $form is an instance of your form)

 $form->setValidationGroup(array( 'email', 'country', )); 
+3
source

Source: https://habr.com/ru/post/1485631/


All Articles