Implementing Conditional Logic

Summary: Creating dependent fields that appear based on user selection.

The library supports dependent fields without requiring custom JavaScript.

  1. Start Block: Use $form->startDependentFields($parentField, $showValues);. The block displays only if the parent field matches one of the provided values.

  2. Add Content: Add any number of inputs or HTML elements.

  3. End Block: Close the block with $form->endDependentFields();.

Note: Dependent fields must not start with the same field name as their parent field.