show rest of a form if a checkbox is ckecked in ruby on rails

前端 未结 6 999
终归单人心
终归单人心 2020-12-16 08:58

I need to ask to my user if will pay a service with credit card...if it checked the option pay_with_card? it must show the rest of the form, that ask for other data like car

6条回答
  •  庸人自扰
    2020-12-16 09:40

    You can use JS for it or move pay_with_card out of form like:

    <%= link_to 'pay with card', your_current_path(:pay_with_card => 1) %>
    <%= form_for(...) do |f| %>
      <% if params[:pay_with_card] %>
        <%= # fields for card %>
      <% end %> 
    <% end %>
    

提交回复
热议问题