0

I want to format form fields with Boostrap CSS.

I have following code in form view file:

<p>
  <%= f.label :country %>
  <%= f.select :country, ["India","USA","Australia"] %>
</p>

I want it to format as:

<select class="form-control">
    <option>India</option>
    <option>USA</option>
    <option>Australia</option>
</select>

I have tried few different ways that I thought would work, but no success.

1
  • <%= f.select :country, ["India","USA","Australia"], {}, { :class => 'form-control' } %> try this Commented Jun 8, 2015 at 9:56

1 Answer 1

1
<%= f.select :country, options_for_select(["India", "USA", "Australia"]), class: "form-control" %>

It will generate the desired output.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.