I’m trying to get multiple select to work with the phoenix_html form helpers
<%= select f, :challenge_ids, ["foo": "1","bar": "2","baz": "3"], class: "form-control", multiple: "" %>
but only the id of the last selected item gets sent to the server in the params
%{"challenge_ids" => "3", "content" => "", "name" => ""}
I have also tried changing :challeng_ids
to :"challenge_ids[]"
trying to get something similar to a rails output for a multiple select tag, but this didn't make any difference
Aaron's PR for adding multiple_select was merged into phoenix_html. Here's an example from the docs for multiple_select/4
in case someone else stumbled across the same problem:
# Assuming form contains a User model
multiple_select(form, :roles, ["Admin": 1, "Power User": 2])
#=> <select id="user_roles" name="user[roles][]">
<option value="1">Admin</option>
<option value="2">Power User</option>
</select>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With