Field to track (only Checkbox, Radio, Select)
Field to track is a feature to track specific field value to e.g. filter out some options from optionsList
property in Radio, Checkbox or Select field.
If you will take a closer look to the optionsList
property inside those fields, you can easily see that it is method based prop with param inside to hold the value from - you guessed it - fieldToTrack
prop.
CheckboxFieldStructure | RadioFieldStructure| SelectFieldStructure = {
// ... rest of the CheckboxFieldStructure | RadioFieldStructure | SelectFieldStructure,
fieldToTrack?: FieldTrackerInterface;
}
interface FieldTrackerInterface {
fieldName: string;
useSamePath?: boolean;
}
Example
Let's say we don't want to give user to choose the same value in two different select
fields because it should choose the favourite food and second favourite too :)
useSamePath
example
useSamePath
property is allowing to only put the field name inside the fieldName
property without replicating the whole path to that field. You can spot the difference inside the schema.
It is super useful inside nested sections or array fields, since you can easily point to the nearest sibling field.