I have multiple forms which will be generated 4 times with the same field with a loop. And I am confused about how to submit these fields in the same database table with a loop.
my form looks like this:
<form action="http://localhost/pages/edit" method="post" name="form">
<p><label for='short'>Name</label><br/><input type="text" name="title[]" value="" /></p>
<p><label for='short'>Url</label><br/><input type="text" name="url[]" value="ddd-df-adsfasd--asdf" /></p>
<p><label for='short'>Short Description</label><br/><textarea name="shortdesc[]" cols="90" rows="12" id="short" size="40" ></textarea></p>
<p><label for='long'>Long Description</label><br/><textarea name="longdesc[]" cols="40" rows="5" id="long" ></textarea></p>
<input type="hidden" name="category_id[]" value="124" />
<input type="submit" name="submit" value="Update" />
</form>
This form contents will be generated 4 times. And I am confused about how to take these values to the controller and add then to database.
forattributes are only relevant if they relate to input fields with the sameidattribute value. Because you have repeating form fields, you should append an incremented number to eachforandidvalue becauseidvalues must be unique in a valid HTML document.