E
E
EvgMul2019-01-07 14:05:32
Yii
EvgMul, 2019-01-07 14:05:32

How to set validation for a nested parameter array in Yii2?

The crux of the matter is as follows.
There is a complex form where there are input fields with the name of the view:

<input type="text" id="products-resourcesfiles-7-category" class="form-control" name="Products[resourcesFiles][7][category]" tabindex="1">
<input type="file" id="products-resourcesfiles-7-file" class="form-control" name="Products[resourcesFiles][7][file]" tabindex="1">

Tell me, please, is it possible to set validation rules for such arrays in the rules() of the model? And if possible, tell me exactly how syntactic this is done?
Thanks in advance to all who respond.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arman, 2019-01-07
@Arik

Some validators have an attribute allowArray
If a more complex structure, then I create subforms-models and when initiating the main form I create them, when I save, first I save an array of subforms, and then the main form

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question