Luka Kerr Luka Kerr - 3 months ago 20
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.

The

input_html: { class: "form-dropdown" }
isn't changing the style. How am I able to properly add a class to the simple form
collection_select
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

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" } %>

or

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