2013-01-15 18 views
5

私は、単純なフォームを使ってラジオボタンとは別のデータ属性をしようとしています。simple_formを使用してラジオボタンにデータ属性を追加します。

私は次のようにレンダリングしたい

-

<input type="radio" name="special_feature[all_editions]" id="special_feature_all_editions_true" value="true" data-enables="edition_select"> 
<input type="radio" name="special_feature[all_editions]" id="special_feature_all_editions_false" value="false" data-disables="edition_select"> 


<%= f.input :all_editions, 
     as: :radio_buttons 
     %> 

私はdifferrentデータ属性を追加する方法任意のアイデア?

答えて

0
form.radio_button(all_editions, txt, :data-data_attr => some_variable) 

または

<%= f.input :all_editions, 
     as: :radio_buttons, 
     'data-data_attr' => 'some_variable' 
%> 
+3

そして、私はラジオボタンにコレクションを渡した場合、どのように私は、コレクションの値に応じて、データの属性を設定することができますか? = form.input:zip、:as:ラジオ、:collection => Zip.all、: 'data-enable_dropdown' => '??' –

関連する問題