Form Rules Overview

Forms can be dynamic, where the answer to one question changes the rest of the form. One answer may allow skipping the next three questions, while another requires answering additional questions. Fields like these are called conditional fields. Once you have decided which fields are conditional, use a Form Rule to determine what happens based on the answer to that question (for example, skips page 3 and goes to page 4 on a multi-page form).

As of Liferay 7.4, form fields can even be hidden. This means that a data provider can populate a hidden field, and the hidden field can be used in a rule to dynamically alter the form.

Form Rule Conditions and Actions

Rules have two components:

  • Conditions determine whether any actions are executed.
  • Actions determine what happens if the condition is met.
note

Rules are stored in the database in JSON format by default.

Users can choose OR or AND to define the relationship between multiple conditions:

  • OR: The action is triggered if any of the conditions you specify evaluates to true.
  • AND: The action is triggered only if all the conditions you specify evaluate to true.

Use OR and AND to define conditions for your actions.

Accessing the Rule Builder

  1. Navigate to the Form where the Form Rule is to be applied.

  2. Click on the Rules tab.

    Click on the Rules tab.

  3. Click the Add button (Add) to get started.

Specifying Conditions

When building a rule, you must specify a field (for example, Are you over 18?), a condition (Is equal to), and the Value (Yes/ No) to be compared against. If the condition’s if statement is true, the action is triggered. If it is false, nothing happens.

ConditionDescription
Is equal toChecks whether the inputted value is equal to the condition. Example: if a language matches Spanish, then trigger the action.
Is not equal toChecks whether the inputted value is not equal to the condition.
ContainsChecks whether the inputted value contains the value.
Does not containChecks whether the inputted value does not contain the value.
Is emptyChecks whether a field is empty.
Is not emptyTakes an action as long as a field is not empty.
UserChecks whether the user belongs to a certain Role. If yes, the action is triggered.

Form Rule Actions

The following Actions are available:

The following Actions are available.

ActionDescription
ShowSets the visibility of a form field based on a predefined condition.
EnableUse a predefined condition to enable or disable a field.
RequireUse a predefined condition to make a field required.
Jump to PageBased on user input, skip over some form pages directly to a relevant page. This rule doesn’t appear in the rule builder until a second page is added to the form.
Autofill with Data ProviderUse a data provider to populate fields when a condition is met in another field.
CalculatePopulate a field with a calculated value using data entered in other fields.

Capabilities

Product

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy