Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add data attribute to radio buttons using simple_form.

I'm trying to distinct data attributes to a radio buttons using simple form.

I want to render the following -

<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
        %>

Any idea how I add the differrent data attributes?

like image 339
Finnnn Avatar asked Nov 12 '22 13:11

Finnnn


1 Answers

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

or

<%= f.input :all_editions,
        as: :radio_buttons,
       'data-data_attr' => 'some_variable'
%>
like image 55
Sachin R Avatar answered Nov 15 '22 05:11

Sachin R