Monday, April 20, 2015

How to get ALL values from Multi-select list via POST in CakePHP

I hope I could get some help on this. I have a Multi-select List as part of a form in my view that is populated automatically when you move values to it from another list. My HTML code for my list looks as follows:

<select name="data[Group][Group][]" multiple="multiple" style="width:200px; height:200px" id="list2">      <option value="1" selected>Super User</option>      <option value="3">Admin</option>      <option value="20">Group1</option>      <option value="27">Group2</option>  </select>

What I want to accomplish is to get ALL values of the list via POST in my controller when I click Submit button. I'm only getting ONLY the selected values. For example, if "Super User" is selected, I'm only getting:

[Group] => Array      (          [Group] => Array              (                  [0] => 1              )        )

But I would like to get all values:

[Group] => Array      (          [Group] => Array              (                  [0] => 1                  [1] => 3                  [2] => 20                  [3] => 27              )      )

Any suggestions will be greatly appreciated!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: