0
votes

In Gravity Forms, I have a form containing some input fields asking for number of rooms for each room type.

How can I dynamically add input fields for number of each content in the room? Eg if the previous input field was entered as Bedrooms: 2

Then how can I dynamically add a section or table asking for quantity of contents for each room such as:

Bedroom 1
Bed (Kind): n
Bed (Queen): n
Content N: n...

Bedroom 2
Bed (Kind): n
Bed (Queen): n
Content N: n...

Is there a advanced field to do this? I guess I may need to use JS to do this? If so, how can I make sure these fields can be seen in entries?

I'm thinking of using table, but not sure how to with Gravity Forms.

1
Not sure about this, but have you considered using conditional logic? If I recall correctly, it is an inbuilt feature but effectively it would work something like "only show bedroom 1 section if no_of_room is equal to or is more than 1" and then "only show bedroom 2 section if no_of_room equals to or is more than 2" Was initially thinking about the Dynamic population feature but not sure it would really apply in this case. - Flick
Yeah that is what I thought of too. But if I have a max of 10 room numbers allowed then I would need to setup 10 or so conditional logic and input fields, right?! - Qwerty
How would one show sections? Like you mentioned Bedroom N section which wraps input fields for the number of contents in a room...is it possible to group these into section in Gravity Form? If so how? - Qwerty
gravityhelp.com/documentation/page/Section_Break I can't say if having multiple sections is the best way forward though. One other option might be to create these repeating list fields: gravityhelp.com/documentation/page/List (and change them to other types using e.g. gravityhelp.com/documentation/page/Gform_column_input) - Flick

1 Answers

2
votes

Your best bet out of the box is using the List field. You can enable multiple columns for each bedroom feature (i.e. "Bed (King)", "Bed (Queen)", "Content", etc) and then each bedroom would be represented by a row on the list field. The user can add/remove bedrooms via a plus/minus UI at the end of each row.

Alternately, if you will have a large number of fields per row, I have a perk in the works called "GP Nested Forms". It's a little easier to show how it works than explain (see the video below) but the primary purpose is a clean way to include decent sized forms within other forms, especially when you need to add multiple instances of the child form.

http://www.screencast.com/t/p7sAHutMVfG

If this interests you, you can pick up a copy of Gravity Perks here and I can send you a copy of the Nested Forms perk (not yet publicly available).

Edit

This has been further polished here:

https://gravitywiz.com/documentation/gravity-forms-nested-forms/