Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.declarativeforms.com/llms.txt

Use this file to discover all available pages before exploring further.

If you have not created a form before, start with Create a form.
form.yaml
version: 1
title: "Example form"
description: "A comprehensive multiple_select example."

sections:
  - id: section_1
    title: "Section 1"
    fields:
      - id: question_1
        type: multiple_select
        label: "Question 1"
        options:
          # String options use the same label and value.
          - "Option 1"
          - "Option 2"
          - "Option 3"
        validators:
          - required

      - id: question_2
        type: multiple_select
        label: "Question 2"
        options:
          - label: "Option 1"
            value: "option_1"
          - label: "Option 2"
            value: "option_2"
          - label: "Option 3"
            value: "option_3"
        validators:
          - required
          # On multiple_select, min and max control the number of selected options.
          - type: min
            value: 1
            message: "Select at least 1 option."
          - type: max
            value: 2
            message: "Select no more than 2 options."
          - type: expression
            expression: "!((data.question_2 || []).includes('option_1') && (data.question_2 || []).includes('option_3'))"
            message: "Do not combine Option 1 and Option 3."

      - id: question_3
        type: multiple_select
        label: "Question 3"
        # When allow_other is true, an "Other" option with a free-form text input is shown.
        allow_other: true
        options:
          - "Option 1"
          - "Option 2"
        validators:
          - required

    next: done