I add new inputs by jquery and each input field have name="Model[item][]" , then I check it by EachValidator like this:
['item','each','rule'=>['required']]
where $item is array but problem is: I get back 1 error message for all $item array but I need error message for eache element of the array (for each input field)
when you add a error for a name this error will be assigned for each input with that name. looks like you need to check it without yii validator, but it is bad solution i guess.
maybe a little crunchy, but you can create name for each item with counter (like name1, name2, etc)
and create custom validator assigning for each name.
First give the ‘hidden’ value to your concerned inputs instead of adding them with Jquery (hiddenInput() method)
And you will make them visible with jquery by changing the input type.
In your Model you should use the ‘when’ property to specify the conditions on which the rules should be applied. For exemple your field will be required when a checkbox is checked.
Notice that yii2 applied rules on hidden fields.
Hope it will help, i never tried all of this myself but it should work. Look at the yii2 guide on the Conditional validation section it will help you.