Luka Kerr Luka Kerr - 1 year ago 231
CSS Question

Customising Simple Form Collection_Select

I've got this simple form and I want to be able to style the dropdown menu with css.


input_html: { class: "form-dropdown" }
isn't changing the style. How am I able to properly add a class to the simple form
to style it in css, or is there any other way I can style the dropdown menu?

This is my simple form:

<%= simple_form_for @document do |f| %>

<%= f.collection_select :category_id, Category.all, :id, :name, {promt: "Choose a category" }, input_html: { class: "form-dropdown" } %>

<%= f.input :title, label: "Title", label_html: { class: 'form-input' } %>

<%= f.input :pdf, label: "Upload document:" %>

<%= f.button :submit %>

<% end %>

Answer Source

leave off input_html: thats why it is not working. define it like this:

<%= f.collection_select :category_id, Category.all, :id, :name, {promt: "Choose a category" }, { class: "form-dropdown" } %>


 <%= f.collection_select :category_id, Category.all, :id, :name, promt: "Choose a category", class: "form-dropdown" %>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download