What can it do

Conditional Logic allows you to take actions based on a user's interaction with the form.

Some examples:

  1. Send an admin email to sales@example.com if the user selects Sales in the Type of request field
  2. Show Order ID field is the user selects Refund in the Issue type field
  3. Show a text message if the user selects Yes in the More info field
  4. Hide submit button if the user selects No in the Accept Terms field
  5. Trigger MailChimp if the user chooses Yes to the Subscribe checkbox field
  6. Redirect to http://example.com/next if the user selects Yes to Give Me Next Steps field

How to access it

To access the conditional logic panel click on the Logic icon on the top-left corner on the form edit page.

conditional-logic-form

How does it work

A logic step has two parts:

  1. Conditions: This is user input or selection, example: field32 is Yes
  2. Actions: Events that happen if a condition is true, example:
    redirect to http://example.com/

Conditions

A condition is user input or selection. Conditions can use one of the following comparison types:

  1. is
  2. is not
  3. is not empty
  4. is under
  5. is over
  6. contains

Actions

Actions are events that happen when a condition is found true.

There are 7 possible actions:

  1. show fields
    You can show certain fields based on user input. Example:
    Condition: if Issue Type is Refund
    Action: show fields Order ID, Comments
  2. send email(s) to
    You can send email notifications to certain email addresses. Example:
    Condition: if Issue Type is Sales Enquiry
    Action: send email(s) to sales@example.com
  3. redirect to
    Redirect the responder on form submit. Example:
    Condition: if Your Comments contains Confused
    Action: redirect to example.com/help/faq
  4. set value
    You can set the value of a field if certain conditions are met. This is a powerful tool when used alongside math formulas.
  5. trigger addon
    FormCrafts has dozens of third-party addons. By default all enabled addons are triggered when you submit the form. Using this logic you can choose to trigger an addon only when certain conditions are met. Example:
    Condition: if Newsletter is "Yes, please do"
    Action: trigger addon MailChimp
  6. disable the form
    You can prevent the user from submitting the form, or moving to the next page, if certain conditions are met.

Some examples

1. Show fields conditionally

We are creating a support ticket form and we ask the user for the nature of their issue. Based on their selection we will show links to some online resources. If they are not satisfied, we will allow them to submit a complaint.

We begin by adding a checkbox field labelled Issue Type and some possible options. Next we add text fields, one for each issue type containing links to resources. We add another checkbox field with one option, no==This does not resolve my issue and then a comment field and submit button.

We will configure logic steps as such:

Using conditional logic in forms
Using conditional logic in forms

The first three logic steps show text fields containing links based on user's Issue type selection. They also show the This is not helpful field.

The 4th logic step shows the Describe the Issue field and the Submit button if the user checks the This is not helpful checkbox (whose value is no) or they select the Issue Type as Other.

Note: we don't have to manually hide fields. If a field is set to show based on a conditional logic step then it would automatically be hidden on page load.

2. Send email to / redirect

Our organizations has different departments, but we want to use a common form to get user response. We can use conditional logic to route the responses to the appropriate department, and then also redirect the user to a URL for further information.

We add a checkbox field to our form labelled Department with some options.

Next we configure our logic steps as such:

Conditional logic to send emails and redirect
Conditional logic to send emails and redirect

3. Set value of

We are creating a quiz form. Once we have added all the question fields, we add two Hidden Fields to our form (Add Field -> Other -> Hidden), labelled Score and Message. We edit the Score field and under value we use math formula to sum the question fields. This hidden field will contain the user's quiz score. We leave the message field empty, but note the field ID, field19

Now we use conditional logic to show the user a message based on their score. If their score is less than 3, the message is, Next Time, and so on ...

Conditional logic to personalize message
Conditional logic to personalize message

The set value action uses this format

fieldID: field value

So in our case:

field19: Next Time

We have the message stored in a hidden field. Now we will show this message when the user sees the success text on completing the form. The success message is below your form.

Customizable success message
Customizable success message

Special cases

1. Datepicker field

While using logic the value of a datepicker field is the difference of the selected data and today. If today is 1-Jan-2020, and the user selections 14-Jan-2020 in the datepicker field, the value used for logic is 14.

2. Fileupload field

With a fileupload field the value is the number of files uploaded so far.

3. Tabular field and Matrix field

These fields are a composite of smaller fields, and cannot be used with conditional logic.