Reputation: 893
I am trying to get an array of values from phalcon using a multiple select.
Here is the select code
{{ select("inbox-user", getUsers, 'using': ['id_admin', 'name_admin'], 'multiple' : 'multiple', 'class' : 'form-control select2') }}
And here is the code that receives the values in the controller.
$row->inbox_user = $this->request->getPost(("inbox-user"));
If i dump out what i receive it returns a string, usually the last number. So if the select form selected 13,14,15 i get the following returned when i dump it out
var_dump($row->inbox_user);
// string(2) "15"
Now normally with standard php i just add [] after the ID and that does the trick but when i add [] after inbox-user[] in both the select and the controller code it just prints out NULL.
I also tried wrapping it as an array like this:
getPost([("inbox-user")]);
But that returns NULL
If i try wrapping getUsers like this
{{ select("inbox-user", [getUsers], 'using': ['id_admin', 'name_admin'], 'multiple' : 'multiple', 'class' : 'form-control select2') }}
that doesnt work either. Any ideas how i get it to return an array in Phalcon and Volt?
I appreciate any help you can give and if i was unclear or you need more specific data please let me know and i will be happy to add it.
Upvotes: 1
Views: 2587
Reputation: 358
To get the values on controller in array you must have to change the name of select box with array indicator [], in your case the name of select box must be inbox-user[].
Upvotes: 4