Checkbox Field Type

Description:
The checkbox field type allows users to select a true or false value by checking or unchecking a box. It provides a simple and intuitive interface for capturing binary decisions, such as agreeing to terms, activating features, or indicating preferences.


YAML Definition

- name: receive_newsletter
  type: checkbox
  display_name: "Receive Newsletter"
  guidance: "Tick the box if you wish to receive our newsletter."
  required: false
  default_value: false

Attributes

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

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

  • display_name (string): Optional.
    The label displayed next to the checkbox in the user interface. If not provided, a formatted version of name is used.

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

  • required (boolean): Optional.
    If true, the field must be explicitly checked or unchecked by the user.

  • default_value (boolean): Optional.
    The default state of the checkbox (true for checked, false for unchecked).

  • readonly (boolean): Optional.
    If true, the checkbox is read-only and cannot be modified by the user.

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


Example

- name: terms_accepted
  type: checkbox
  display_name: "I agree to the Terms and Conditions"
  guidance: "You must agree to the terms and conditions to proceed."
  required: true
  default_value: false

In this example:

  • The terms_accepted field is displayed as a checkbox with the label “I agree to the Terms and Conditions”.
  • The field is marked as required, so the user must check the box to proceed.
  • The default_value is set to false, so the checkbox is unchecked by default.

Usage Notes

  • User Interaction: The checkbox field provides a clear and straightforward way for users to make binary choices.

  • Default Values: Setting a default_value helps define the initial state of the checkbox when the form is first displayed.

  • Validation: If a checkbox field is required, ensure that form validation checks whether the user has made a selection.

  • Accessibility: Use descriptive display_name and guidance to assist users in understanding the purpose of the checkbox.

  • Common Use Cases:

    • Consent: Obtaining user agreement for terms, policies, or consent forms.
    • Preferences: Allowing users to opt-in or opt-out of features, newsletters, or notifications.
    • Settings: Enabling or disabling specific functionalities within an application.

By incorporating the checkbox field type into your schema, you provide users with an intuitive control for making simple yes/no or on/off decisions, enhancing the usability of your forms and ensuring accurate data capture.


Copyright © 2024 Caseblocks Limited.