Ninja Forms is one of the most popular form plugins for WordPress.
The Ninja Forms Conditionals Extension allows you to create “smart” forms that can change dynamically based upon user input. Options can be added to dropdown lists based upon other input, or fields can be hidden or shown.
How to Use the Conditional Logic Extension
First, you’ll need to download the extension and activate it on your WordPress website.
Once you did, the plugin will display a new conditional logic option under the advanced tab.
Step #1: Create a new form
To create or edit a form, navigate to Ninja Forms -> Dashboard, and click on the form you would like to edit.
Alternatively, you can click on the Add New button to add a new form.
Step #2: Set to conditional fields
In this step, we will add two fields. The first field will ask the visitors a question, and the second field will appear based on what the visitor answered.
For example, the first field will ask the visitors if they have any food allergy and the second field will only appear if they answer Yes.
Drag the fields to the desired location and set their values and options. When done, click on the advanced tab to set the conditions.
Step #3: Conditional rules
Once clicked on the conditional logic button, you’ll need to create the fields’ rules.
In the first box, under the When field, you’ll need to set the condition that needs to be met for the rule to execute.
In the second box, under the Do field, create the rules to execute when the conditions are met.
For example, if we would like to display the allergies list only once the visitor selected yes, select the option under the when and make it equal to yes.
Once this condition is true, set the allergies list field under the done box and set it to show field.
Additionally, you can add multiple Dos by clicking on the plus icon and making the field required.
In the last box, you can set the behavior to the fields if the condition did not meet.
If the visitors selected No to the food allergies question, the condition wasn’t met, and therefore, the allergies list should be hidden.
Once done, make sure to click Done and test the form.