2013-01-15 110 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 =>:radio,:collection => Zip.all,:'data-enable_dropdown'=>'??' –

相關問題