Search code examples
ruby-on-railsruby-on-rails-3simple-form

newbie: simpleform, how to set id for a collection input field?


How would one set:id => "myvalue" for a simpleform collection input field? and or on a sidenote, im also trying to set the ID of age_from like id => "age_from" cannot figure out how to do both, seems very lacking docs on these.

Tried all possible combinations I could comeup with:

= f.input_field :age_to,
  :label => "Age from",
  :collection => 18..60,
  :select => 19 <------- set this to '19' for this collection?
  :style => "width: 50px !important",
  :id => "myid" <------- how to set id for this collection?

Solution

  • f.input_field :age_to, :label => "Age from", :collection => 18..60, 
    :selected => 19, :style => "width: 50px !important", :input_html => { :id => "myid" }
    

    Hope it works to set id and show selected value!!!