In PeggyForms it is easy to build simple or large forms. In many cases you may need something like a container to group fields. In example:
- to easily add and maintain rules on a particular part of your form.
- to allow users to repeat a part of your form as needed, like a product choice, person information etc
For these purposes PeggyForms has the Container / repeating section field.
For this how to, you should be familiar with the basics of Peggy Forms. If you are not then watch this video tutorial first.: PeggyForms basics.
Lets assume that we want a simple form where visitors can add 1 or more participants for some reason. We start by adding the container field:
2. Creating the sub form
We call the form inside a container a sub form. To start building the sub form, click the container field and press the icon in the field toolbar.
Here, we create a form like this:
Now press [Return to main form] button. In your mainform you will see this sub form inside the container field. If not, you have to press the button in the field toolbar to display the containers content.
3. The features
If users must be able to add and remove instances of this sub form, check the [Show add/remove controls] under the Content tab. In our example, we do want this. The visitor must be able to add 1 or more participants in his submission. So we enable this option and set the minimum repeats to 1 and maximum repeats to 4. We do not want more than 4 participants per submission. We leave initial repeats to 1, thats fine!
Optionally you can ajust the labels of the add and remove button under the Labels tab.
4. Rules and logic
Another big advantage of using containers is rules and logic. With a container, you easily can add and maintain rules for a group of fields. You can also accomplish this by adding field rules as reference to other fields. Ofcourse you also can use rules and logic inside the sub form as you are used to.