09-19-2018, 12:43 AM (This post was last modified: 09-19-2018, 02:02 AM by kvanaraj.)
(09-18-2018, 11:09 PM)Wouter60 Wrote: Your greatest challenge is: how to repopulate only the fields that were enabled.
If you carefully study my last reply, you will see that the names of the input fields aren't just noc[] or cbx[], but the id of the current row is used as the key of the element.
Field arrays without a user defined index, automatically get a numeric key starting with 0 in the $_POST data.
Let's say you have 5 fields named "noc[]", and you only enable the second and fifth. In $this->input->post('noc') you will see just 2 elements being returned: noc[0] and noc[1]. So it's impossible to find out which ones were posted.
If the 5 fields have the names "noc[1]", "noc[2]", "noc[3]", "noc[4]" and "noc[5]", now after you post the form, $this->input->post('noc') will hold noc[2] and noc[5].
You can dynamically assign the keys of noc[…] in your foreach {} structure and repopulate them with set_value():
(View)