Answer the question
In order to leave comments, you need to log in
How to do array validation in Active Form Yii2?
Is it possible to somehow validate an array of models, or how to say it correctly, in general, a contact form, fields are added dynamically.
<div>
<select name="type[0]">
<option value="ok">Одноклассники</option>
...
<option value="vk">ВК</option>
</select>
<input type="text" name="value[0]" />
</div>
...
<div>
<select name="type[0]">
<option value="ok">Одноклассники</option>
...
<option value="vk">ВК</option>
</select>
<input type="text" name="value[0]" />
</div>
Answer the question
In order to leave comments, you need to log in
This is the so-called tabular input .
And your form is incorrect, you will get only one value type[0] and value[0].
<div>
<select name="social[0][type]">
<option value="ok">Одноклассники</option>
...
<option value="vk">ВК</option>
</select>
<input type="text" name="social[0][value]" />
</div>
...
<div>
<select name="social[1][type]">
<option value="ok">Одноклассники</option>
...
<option value="vk">ВК</option>
</select>
<input type="text" name="social[1][value]" />
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question