Appearance
FormModel
Can be created by using createForm method. Has following properties:
Stores:
$values- current form values$focused- path to the field which's in focus right now (set byfocusedevent and reset by blured)$initialValues- contains initial values (if store was passed in params ofcreateFormit's gonna be used right away instead of creating another one)$isDisabled- global form disable state (passed from params increateForm)$submitCount- counter of how much timesubmitevent was called$dirty- Map where keys are field paths and values are booleans. Contains fields which been changed bychangecalls$touched- Same as$dirtybut contains "touched" state for touched fields$errors- Contains error map returned by validation method. CheckErrorsMaptype from '@filledout/core'.$externalErrors- SameErrorsMapas$errorsbut entire store is provided by one passed into createForm call.
Derived Stores:
$isValid- boolean flag which reflects if$errorsare empty or not$isDirty-truewhen some field is dirty$isFocused-truewhen$focusedis not empty$isTouched-truewhen some field is touched$isSubmitted-trueif$submitCountis> 0
Events:
submitted- Called when form is submitted successfully. IMPORTANT: by default it's not called from anywhere it's either responsibility of schema validation adapters or you if you're not using validators you should manually bind sample({ clock: submit, target: submitted }) in factoryInterceptor or in your custom createForm decorator function.blured- called from UI when field lose focusfocused- called form UI when field get focusedchanged- called when field explicitly changes (has field path and value as a payload)rejected- called when submitted with errors (has errors and valueus as a payload). IMPORTANT: it's not called from anywhere by default just likesubmittedso it follows the same logic as described above.put- Accepts values to replace current values withreset- Resets form to default state. All touched/dirty and other states are cleared, values set to initialValues (if initialValues is a store it's $values gonna be set to current initialValues state)set- Sets field value (accepts field path and value) without triggering dirty statepatch- Accepts values to deepmerge with current form valuessubmit- Submits a form (by default it's not redirected to submitted/rejects, check notes above)change- Sets field value (accepts field path and value) and triggers dirty statevalidate- Calls form validation (by default doesnt do anything but validators will subscribe to it under the hood)
Misc:
showValidationOn- List of ValidationVisibilityCondition set while creating a form (or global value if nothing was passed intocreateForm)fields- Field proxy object which allows you to access field units (which gonna be generated on the "fly"). IMPORTANT: do not use it in UI code because it's gonna break reference equality. For UI usage in UI check specific section of the docs