Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
stylenone

Introduction

Conditional logic is used on forms and decision tools to:

  • progressively show questions or information

  • show different questions or information according to previous responses

Process

Applying and testing conditional logic on forms can take a bit of trial and error. You’ll do a lot of refreshing of this published/preview page while setting up an testing configuration.

You’ll need to embed your Drupal form in a Landing page in the CMS and publish or preview that Landing page for testing. (While there is a test function in Drupal forms, we prefer to test on a front end view.)

You’ll do a lot of refreshing of this published/preview page while setting up an testing configuration.

Follow this basic process:

  1. Plan your logic first (see below)

  2. Add all your questions and information in the CMS first. Hidden/visible logic can be applied on text fields. More specific logic is mainly used with radio and checkbox elements (e.g. Q2 is visible if the response to Q1 is 'no').

  3. Progressively apply conditions and keep testing.

Tips

When you are in the Build mode on a webform, you can see if conditional logic has been applied to a question or piece of text by looking in the ‘Conditional’ column.

...

1 = State: Visible or Hidden (usually 'visible')

2 = All, Any or One (to add more than 1 element so that ‘all’ or ‘any’ are applicable, click the plus icon next to the element)

3 = Options include: Empty / Filled; Checked / Unchecked; Value is /Value is notIn this example, we can see that question 4 is set to be visible if the answer to question 3 is ‘Individual’. You can infer that there’s probably another conditional logic configuration set up on another question if the answer to question 3 is something else.

Numbering: Because you’re showing and hiding information and questions according to answers chosen on previous questions, it doesn’t make sense to number the questions on the final published form or tool. But while planning the logic and building the form or tool, it really helps a lotit’s really useful. You can see on the table below how the numbering helps state the logic/conditions. And when you’re a lot when you might be trying to select items on a long dropdown.

Plan your logic

People often set up a flowchart to map out the logic of a form or tool. I find it helpful to transfer this info a document to plan the numbering and the logic. Here’s an example:

Question / Text

Notes

Conditions / email handler

1 What is your full name?*

Text field, required

2 What is your email address?*

Email field, required

3 What is your phone number?

Phone number field (10 digits), not required

4 What type of enquiry do you have?

4a Question

4b Complaint

Radios, required

na

5 What is your enquiry about?

Radios, required

Responses only for

Visible if value is 4a

5a Apples

If Q4 value is 4a

and

Q5 value is 5a

email apples@vic.gov.au

5b Bananas

If Q4 value is 4a

and

Q5 value is 5b

email bananas@vic.gov.au

5c Oranges

If Q4 value is 4a

and

Q5 value is 5c

email oranges@vic.gov.au

6 What is your complaint about?

Radios, required

Visible if Q1 Q4 value is 1b4b

6a MelbourneIf Q1 value is 1b

6b Geelong

6c Phillip Island

7 The next question (specifically for questions about Melbourne)

Visible if Q4 value is 4a

and

Q6 value is 6a

email melbourne@vic.gov.au

6b Geelong

6c Phillip Island

8 The next question (specifically for complaints about Melbourne)

Visible if Q4 value is 4b

and

Q6 value is 6a

9 The next question (specifically for complaints about Geelong)

Visible if Q4 value is 4b

and

Q6 value is 6b

Email handlers can have logic too

...

The State for email handlers is either Enabled or Disabled. The conditions required that all 3 elements needed to have the set value in order for the handler to take the specified action (i.e. send to the specified email address).

...

Disable submissions or hide the submit button

On the Settings tab of the form there’s a checkbox to disable xxxx

To remove the default Submit button, xxxxxxxxxx