<%= form_for @subscription, :url => subscription_path(@subscription.subscription_id), :html => {:method => :put, :class => 'form-horizontal'} do |f| %>
<%= label_tag :plan_name, 'New plan', :class => 'col-sm-2 control-label' %>
<%= select_tag :plan_name, options_for_select(@plans), :class => 'form-control' %>
<%= label_tag :type_change do %> <%= radio_button_tag :type_change, 'DEFAULT', :checked => true %> Default policy <% end %>
<%= label_tag :type_change do %> <%= radio_button_tag :type_change, 'POLICY' %> Specify Policy <% end %>
<%= label_tag :type_change do %> <%= radio_button_tag :type_change, 'DATE' %> Specify a date <% end %>
<%= label_tag :requested_date, 'Change Date', :class => 'col-sm-2 control-label' %>
<%= text_field_tag :requested_date, Date.parse(Time.now.to_s).to_s, :class => 'form-control date-picker' %>
<%= label_tag :policy, 'Policy', :class => 'col-sm-2 control-label' %>
<%= select_tag :policy, options_for_select(['', 'IMMEDIATE', 'END_OF_TERM']), :class => 'form-control' %>

Leave blank for default

<%= submit_tag 'Save', :class => 'btn btn-default' %>
<% end %> <%= javascript_tag do %> function onTypeChange() { var value = $("input[type=radio]:checked").val(); if (value == "DEFAULT") { $("#form_requested_date").hide(); $("#form_policy").hide(); } else if (value == "POLICY") { $("#form_requested_date").hide(); $("#form_policy").show(); } else if (value == "DATE") { $("#form_policy").hide(); $("#form_requested_date").show(); } } $(document).ready(function() { onTypeChange(); $( "input[type=radio]").on("click", function() { onTypeChange(); }); }); <% end %>