A2InputFieldState<T> extends formstate’s FieldState<T> and adds non-blocking warnings, dynamic disablers, soft validation, and value-confirmation helpers. It is the field state every Form.* wrapper binds to.
Creating a field state
Pass an initial value to the constructor, then attach validators:Inherited from formstate
A2InputFieldState keeps the full FieldState surface:
Added behavior
A2InputFieldState adds the following on top of FieldState:
Warnings and disablers are evaluated during
validate() and softValidate():
Selection field states
Changed in 0.9.0: Selectable field states now take a single generic and
store full option objects. See the migration
guide.
SelectableOptionsFieldState<G> (single) and SelectableOptionsArrayFieldState<G> (multiple) extend A2InputFieldState for option-based selection, where G extends OptionType<unknown> (an { id, disabled? } shape). SelectableOptionsFieldState’s value is a single option object or null; SelectableOptionsArrayFieldState’s value is an array of option objects. Both hold an options list and validate the selected value against option-derived rules.
setOptions whenever the available options change. When the selected value matches a tracked option, validate() reports the rule’s errorCode as the error.
These are the field states behind Form.Select, Form.SelectSync, Form.MultiSelect, Form.MultiSelectSync, Form.TreeSelect, Form.RadioGroup, and Form.CheckboxGroup. Form.Select and Form.MultiSelect load their options through a loadOptions prop and never read this options list; setOptions only matters there for validationRules. Form.SelectSync and Form.MultiSelectSync render directly from options, so call setOptions whenever your source list changes. Form.RadioGroup and Form.CheckboxGroup render from a required items prop instead — pass the same list to items and to setOptions so validationRules stay in sync with what’s rendered.
Combined field states
IntervalFrequencyFormState<G> combines a numeric interval field with a frequency SelectableOptionsFieldState<G> into one formstate.FormState, for use with Form.IntervalFrequency. See Interval frequency.