0

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

2 Answers 2

1

Maybe this can get you started

Sign up to request clarification or add additional context in comments.

1 Comment

It's best to summarize rather than provide only a link :)
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.