<% form.inputs do %>
<% @account.account_preference.editorial_attributes.each do |key, value| %>
<%= account_pref.input "editorial_#{key}".to_sym, :as => :radio, :collection => options_for(Editorial, key.to_sym), :wrapper_html => { :class => "compact" }, :label => key.titleize %>
<% end %>
<% end %>
How do a change this drop down list to a regular drop down list with out radio buttons?
You could do it this way:
account_pref_options = []
@account.account_preference.editorial_attributes.each do |k,v|
account_pref_options << [k.titleize, "editorial_#{key}"]
end
Then use the select tag helper. If within a form_for model do |f|
tag, do
<%= f.select :field_name, account_pref_options_options %>
If witin a form_tag
tag, do
<%= select_tag(:field_name, options_for_select(account_pref_options)) %>
Check out the EdgeGuides for more information as well as the RoR API.
http://edgeguides.rubyonrails.org/form_helpers.html#the-select-and-option-tags
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.