VD007
VD007

Reputation: 267

Ruby on rails_format form fields with bootstrap

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.

Upvotes: 0

Views: 29

Answers (1)

Arslan Ali
Arslan Ali

Reputation: 17802

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

It will generate the desired output.

Upvotes: 1

Related Questions