I’m developing a site using the CakePHP framework. I have a form which shows a list of entities, with a tickbox for each one allowing you to select it. You then press a button at the bottom of the form saying “Edit selected”.
My usual approach is to give each checkbox input the same name (e.g. row_id) and use the primary ID as the input’s value. However, when you submit the form, CakePHP only seems to return one of the checkbox’s values to the controller in $this->params['url'], rather than any kind of list like I’d expect.
Any tips on the right way to handle this, so that I can find out which rows were ticked?
If you’re using the FormHelper, the easiest way is to create your fields like this:
Etc.. you get the point. If it’s a dynamic list, there always the
forloop.When the form is POSTed, this should give you a server side array like this ($this->data):
Then you can use the Set utility class to extract your IDs (and mess with your data:))