mardi 24 février 2015

Setting values and names for options_for_select

looked around but nothing that is perfect I can find.


I have an array of @agents and want to display them in a multi select form. Currently I have:



<%= f.select(:agents, options_for_select(@agents), {},{multiple: true, size: 10}) %>


Which shows this:


Agents array view


I want to chose what to display in the select and possibly have a checkbox if possible?


Attributes are accessible via



<% @agents.each do |a| %>
<%= a.id %>
<%= a.name %>
<% end %>


I want it to look as follows:


enter image description here


Best way for me to do this? Thanks!





Aucun commentaire:

Enregistrer un commentaire