开发者

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)  } %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜