Search code examples
ruby-on-railsruby-on-rails-3formsformtastic

Rails 3.1 Formtastic input custom id or class


I want to make chain selects part inside my Formtastic form. But is it possible to set custom ids for multiple selects for future AJAX replacement?

This doesn't work:

<%= semantic_form_for [:admin, @production_year] do |f| %>
  <%= f.inputs do %>
    <%= f.input :car_model, :label => "CarModel", :as => :select, :collection => Brand.find(:all, :order => "name ASC"), :id => "brand_id" %>
  <% end %>
<% end %>

Solution

  • Options should be passed to the input_html hash, like so:

    <%= f.input :car_model, :input_html => { :id => "brand_id" } %>