Ive been stuck on something for a while and ive been trying to use javascript ect but i feel there is a simpler way. I need to use an if statement to render a form depending on what tab has been clicked. I realised that you cant do something like if tab1.checked
as ruby cant do this. However, in the code below, i thought about adding a param to the tab, and using that in the if statement. Is this possible? code below is my experiment, thanks. Please no javascript suggestions.
<input id="tab1" type="radio" name="tabs" :checked = <% (params[:uk_checked]) %>>
<label class="label-header" for="tab1"> UK Address</label>
<input id="tab2" type="radio" name="tabs" >
<label class="label-header"for="tab2"> International Address </label>
<!-- <section id="content1"> -->
<% if params[:uk_checked] == 1 %>
<%= f.simple_fields_for :address do |fields| %>
<section id="content1">
<%= render "address/fields", fields: fields, addressable: addressable %>
</section>
<% end %>
<% else %>
<%= f.simple_fields_for :address do |fields| %>
<section id="content2">
<%= render "address/international_fields", fields: fields, addressable: addressable %>
</section>
<% end %>
<% end %>
Aucun commentaire:
Enregistrer un commentaire