Reputation: 33
Is it possible to display a form-field only if a specific condition is met?
I want to make something like:
<%= f.input :pregnancies, :as => :radio, :label => "Pregnancies", :collection => [["no", false], ["yes", true]]%>
if :pregnancies = true
then show this input
<%= f.input :preg_nr, :label => "Number of pregnancies" %>
Thanks in advance
Upvotes: 0
Views: 1558
Reputation: 5335
Are you saying you want this page to be dynamic? Where, if a user chooses 'Yes' for Pregnancies, then they are able to choose the number of pregnancies? If this is the case I think you will want to use some type of client side code...something like Javascript or JQuery. Unfortunately my skills are limited here. Hopefully someone will chime in with a code sample for you.
Upvotes: 0