I have a form structure to save information about surveys and questions, this is kind of my code:
<form>
<div class=surveys>
Survey 1
<div class="questions">
Question 1
<input name="value_1">
<input name="value_2">
</div>
<div class="questions">
Question 2
<input name="value_1">
<input name="value_2">
</div>
...
</div>
<div class=surveys>
Survey 2
<div class="questions">
Question 1
<input name="value_1">
<input name="value_2">
</div>
<div class="questions">
Question 2
<input name="value_1">
<input name="value_2">
</div>
...
</div>
...
As you can see I have a form with many elements groups by divs called "Surveys", in which I have also many elements groups by divs as well called "Questions", the number of surveys and questions is defined by the number of elements I bring back from my DB.
This information is send to a controller (I'm using Laravel framework), and I would like to know what is the best way to send this data to the controller to manipulate it by the post request. I'm a bit confused because the inputs name have to be the same in every element, or at least similar, but i don't know how to identify the input so I can match with the question.
Hope you can help me, I would really appreciate.
Do this:
name="survey[".$i."][."$j."]['value_1']"
Where i is index of survey and j is index of question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.