Adding a class to Formtastic radio button
I have a Formtastic radio button collection which is populated by a number of types:
<%= f.input :type_id, :validate => true, :as => :radio, :collection => Type.where(:object_type => 'Post') %>
However, I want to conditionally add a class to each choice, since some of the radio buttons need to be disabled depending on a certain condition.
For example, a :member_class =>
param would开发者_开发百科 be ideal, but I don't believe it exists like :member_label
and :member_value
.
Does Formtastic have the ability to allow this?
<%= f.input :type_id, :validate => true, :as => :radio,
:collection => Type.where(:object_type => 'Post'),
:input_html => { :class => (:class_name if condition_goes_here) } %>
or
<%= f.input :type_id, :validate => true, :as => :radio,
:collection => Type.where(:object_type => 'Post'),
:input_html => { :disabled => (:disabled if condition_goes_here) } %>
精彩评论