Rails toggling closest submit button in a form with radio buttons
- by Timothy
I have a bunch of forms listed in Rails like such
<% parent.children.some_named_scope.each do |child| %>
<% form_for :parent, parent do |f| %>
<% current_value = child.column_to_set %>
<% child.possible_values_for_column_to_set.each do |value| %>
<% f.fields_for :children, child, :child_index => child.id.to_s do |child_form| %>
<%= child_form.label :column_to_set, value.to_s.titleize, :value => value %>
<%= child_form.radio_button, :column_to_set, value, :type => 'radio' %>
<% end %>
<% end %>
<%= f.submit "Submit", :disabled => true %>
<% end %>
<% end %>
How do I set the submit button's disabled to false, dynamically, when it is not current_value and set it to true when it is while the user clicks radio buttons?