I have a form built with the bootstrap_form gem for ruby. within the form I have some radio buttons. the form renders perfectly with the correct labeling in the edit page of the form, however once I save the form and go to the "show" page to see the results, the inputs for the radio buttons are only showing the value of the radio button (which are numbers) and not the custom label name I have assigned. How can I make the custom label appear instead of the value in the show page?
Here is my code:
_form.html.erb:
<%= f.form_group :gender, label: { text: "Gender" } do %>
<%= f.radio_button :gender, 0, label: "Female", checked: true, inline: true %>
<%= f.radio_button :gender, 1, label: "Male", inline: true %>
<% end %>
<%= f.form_group :nationality, label: { text: "Nationality" } do %>
<%= f.radio_button :nationality, 0, label: "Kuwaiti", checked: true, inline: true %>
<%= f.radio_button :nationality, 1, label: "Non-Kuwaiti", inline: true %>
<% end %>
show.html.erb
<p><strong>Full Name:</strong> <%= @profile.name %></p>
<p><strong>Civil ID no:</strong> <%= @profile.civil %></p>
<p><strong>Gender:</strong> <%= @profile.gender %></p>
<p><strong>Nationality:</strong> <%= @profile.nationality %></p>
<p><strong>Mobile no:</strong> <%= @profile.mobile %></p>
<p><strong>Personal Email:</strong> <%= @profile.personal_email %></p>
Thanks for the help in advance!
Update:-
New form code:-
<%= f.form_group :gender, label: { text: "Gender" } do %>
<%= f.radio_button :gender, 1 %>
<%= f.label 'Female', inline: true, checked: true %>
<%= f.radio_button :gender, 0 %>
<%= f.label 'Male', inline: true %>
<% end %>
Tried this suggestion but still getting the same problem, only the the radio buttons are no longer in line and have incorrect formatting.
Aucun commentaire:
Enregistrer un commentaire