Skip to content

Add support for Boolean form fields #36

@doneill

Description

@doneill

Boolean Field Specification

json subschema:

{
  "default": true,
  "deprecated": false,
  "description": "Does the veterinarian require medicine for the animal?",
  "title": "Animal Requires Medicine",
  "type": "boolean"
}
  • default: The initial value assigned to the field. This property is optional.
  • deprecated: A soft-delete flag. When set to true, the field remains in the schema for compatibility but is not rendered in the UI.
  • description: Helper text for the field. This text is displayed in the UI below the field. This property is optional.
  • title: The user-defined label for the field. This text is displayed in the UI over the field.
  • type: Always "boolean". The stored value is a boolean input.

ui subschema:

{
  "conditionalDependents": [],
  "parent": "section-1",
  "type": "BOOLEAN"
}
  • conditionalDependents: An array of section ids that tracks whether any section conditions depend on this field. It is primarily used by the form builder and does not affect the user-facing behavior of the field.
  • parent: The id of the form element that contains this field. This can be either a section or a collection.
  • type: Always BOOLEAN

Action:

  • Generate UI Schema for Boolean form field based on defined spec

Expectation:

  • React Native client app, e.g. EarthRanger, sends json schema to UI Generator and library returns UI Schema for client to redner the form field

Example:

{
  "json": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "properties": {
      "Is_there_anybody_in_there": {
        "deprecated": false,
        "title": "Is there anybody in there?",
        "default": false,
        "description": "",
        "type": "boolean"
      }
    },
    "required": [],
    "type": "object",
    "unevaluatedProperties": false
  },
  "ui": {
    "fields": {
      "Is_there_anybody_in_there": {
        "conditionalDependents": [],
        "parent": "section-1",
        "type": "BOOLEAN"
      }
    },
    "headers": {},
    "order": [
      "section-1"
    ],
    "sections": {
      "section-1": {
        "columns": 1,
        "conditions": [],
        "isActive": true,
        "label": "",
        "leftColumn": [
          {
            "name": "Is_there_anybody_in_there",
            "type": "field"
          }
        ],
        "rightColumn": []
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions