Boolean Field Type

Description:
The boolean field type represents a true or false value. It is commonly used for fields that require a simple yes or no answer. This field type is essential for capturing binary decisions in your application, such as active status, consent agreements, or feature toggles.


YAML Definition

- name: is_active
  type: boolean
  display_name: "Is Active"
  guidance: "Select 'Yes' if active, 'No' if inactive."
  required: true
  default_value: false

Attributes

  • name (string): Required.
    The unique identifier for the field.

  • type (string): Required.
    Must be set to boolean for boolean fields.

  • display_name (string): Optional.
    The label displayed in the user interface. If not provided, the name will be formatted and used.

  • guidance (string): Optional.
    Help text or instructions for the field.

  • required (boolean): Optional.
    If true, the field must be filled.

  • default_value (boolean): Optional.
    The default value of the field (true or false).

  • readonly (boolean): Optional.
    If true, the field is read-only.

  • hidden (boolean): Optional.
    If true, the field is hidden from the user interface.


Example

- name: terms_accepted
  type: boolean
  display_name: "Terms Accepted"
  guidance: "Indicate whether the terms and conditions have been accepted."
  required: true
  default_value: false

Usage Notes

  • User Input: The boolean field can be presented in the user interface as a checkbox, toggle switch, or radio buttons offering “Yes” or “No” options.

  • Validation: Ensure that the input is correctly captured as a boolean value (true or false) in your application logic.

  • Default Values: Setting a default_value is useful when you want the field to have a predefined state, such as false for an unchecked checkbox.

  • Accessibility: Use clear labels and guidance to help users understand the purpose of the boolean field.


By incorporating the boolean field type into your schema, you enable straightforward true/false data capture, which is essential for many decision points in applications, such as feature toggles, status indicators, and user consent fields.


Copyright © 2024 Caseblocks Limited.