5

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?

1 Answer 1

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

or

<%= f.input :all_editions,
        as: :radio_buttons,
       'data-data_attr' => 'some_variable'
%>
Sign up to request clarification or add additional context in comments.

1 Comment

And what if i pass a collection to the radio buttons, how can i set the data attribute depending on the collection value? = form.input :zip, :as => :radio, :collection => Zip.all, :'data-enable_dropdown' => '??'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.