Showing questions depending on an answer

Rules let a form change as someone fills it in: show a text box when they pick “Other”, require a VAT number only for registered businesses, or skip a page.

What you need

A form with at least two questions. Each question has a Field key, which rules use as answers.<key>.

Show a question only when needed

  1. Select the question and open Logic & validation.
  2. Under Show this question when, choose Add condition.
  3. Pick a Field, an operator such as is and a Value.
  4. Choose Preview and try both answers.

Show this question when, built with the condition builder

Add group combines conditions: Match all or any of the following. Edit as expression shows the written form, for example answers.source == "Other".

The other rules

  • Required when: the question must be answered while the rule is true.
  • Valid when: the answer is refused unless the rule is true. For example, answers.vat matches /^GB[0-9]{9}$/.
  • Computed value (read-only): the answer is worked out from other answers.
  • Default value (editable): the answer starts as this and can be changed.

A Panel and Columns have their own Show this panel when and Show these columns when. Hiding one hides everything inside it.

Skip a page

  1. Add a Page break.
  2. Under Skip logic, add a rule: Go to a page, or Finish (submit the form), when this is true.

The first matching rule wins. If none match, the person goes to the next page. Turn off Show the page progress bar in Settings > Look & options when skipping makes the page count misleading.

Buttons and variables

Variables and button actions are on Foldr Cloud now and on appliances from 11.3. In Settings > Behaviour > Variables, Add a variable and read it as vars.key. A Button question can Toggle or Set a variable on On click.

If something does not work

  • Publish refuses a rule. Foldr checks every expression when you publish. today().subDays(90) is refused because today() gives text. Write mash.date.today().subDays(90).
  • An answer to a hidden question is missing. Foldr runs the rules again on the server and drops answers to hidden questions.

To add up a table, see Adding up a table in a form.

Full reference

← All articles