I have a dynamic table, where I can add and delete rows. In each row, there are some inputs where the user can add data to an object.
Right now, I am hardcoding each index number to the name attr. Like this:
<input type="text" name="reports[0][title]">
<input type="text" name="reports[0][description]">
<input type="text" name="reports[1][title]">
<input type="text" name="reports[1][description]">
Is it possible to do something like this:
<input type="text" name="reports[][title]">
<input type="text" name="reports[][description]">
<input type="text" name="reports[][title]">
<input type="text" name="reports[][description]">
And receive the request just like when it was hardcoded indexes?
I need to post multiple objects to the store method in the controller. When I receive the request, I want the data to be like this without hardcoding the indexes.
"reports": [
{
"title": "Title 1",
"description": "Description 1"
},
{
"title": "Title 2",
"description": "Description 2"
}
]
Thanks in advance.