Field Relationships
Exists

Exists dependency

It makes a field to be displayed only given some criteria is met.

Properties for exists dependency

NameDescription
refIt is the reference name of the dependent field
sectionIt is the section/group name of the reference filed.
It is optional and required only if form is a grouped form and the reference field belongs to a different group
valueIt is the value of the reference field
conditionUsed only if value equals special value $condition. Check details below
valueFnUsed onl if the value equals special value '$valueFn`. Check details below

The property value

  • It can either be a single value or an array of values.
  • The current field will be displayed only if the reference field has the same value as the value specified here.
  • In case value is array, it will try to check if it contains any value matching the reference field value.

Special values

These values are special values which has specific purpose

NameDescription
$conditionIt will parse the condition from the condition property and will display the field only if it result is true.
$notemptyIt will display current the field only if the reference field value is not empty
$valueFnIt will execute a function and display the field if result is true. The function name is taken from the property valueFn and it must be passed as an input property fns from the component

Condition

Condition allows to build on advanced criteria's that can satisfy a dependency. The value of this property should be array. It can contain multiple conditions

A condition is divided into four parts:

  • Operand
  • Operator
  • Value
  • Next condition

Model details:

type Condition = [Operand, Operator, Operand | Value, NextCondition?];
 
interface Operand {
    ref: string;
    section?: string;
}
 
type Operator = "===" | ">=" | "<=";
 
type Value = string | number | boolean | Date | undefined | null;
 
type NextCondition = "&&" | "||";

Example

condition: [[{ ref: "<field_name>", section: "<section_name>" }, "===", true]];

Exists dependency example

Schema

{
fields
:
[
[
…
]
[
…
]
[
…
]
]
}

Star us at github

© Copyright 2023 MuiForms