Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't add class on select form helper in Rails 4

Using Rails 4. Can't seem to add class to select. I think other attributes like required, autofocus are also not there:

<%= form.select "availability", options_for_select(1..200), required: 'true', autofocus: 'true', class: 'form-control' %> 

Output is below:

<select id="event_availability" name="event[availability]">   <option value="1">1</option>   <option value="2">2</option>   <option value="3">3</option>   ... </select> 

Any idea? Thanks.

like image 962
Victor Avatar asked Jan 24 '14 16:01

Victor


1 Answers

Try this

<%= form.select "availability", options_for_select(1..200), {}, {required: 'true', autofocus: 'true', class: 'form-control'} %> 

Possible options for third argument are :prompt and :include_blank

like image 150
usha Avatar answered Sep 19 '22 08:09

usha