cofi

cofi

  • Docs
  • Form Demos
  • Components Demos
  • Layout Demos
  • Editor
  • GitHub

›Form Class

Getting started

  • Introduction

Form Class

  • Installation
  • Overview
  • Arguments
  • Id
  • Data
  • Fields
  • Path
  • Component
  • Formatter & Parser
  • Dependencies
  • Required
  • Validators
  • Exclude Term
  • Disable Term
  • Require Term
  • Dependencies Change
  • Context
  • Dirty
  • Invalid
  • Errors
  • Processing
  • Pending Actions
  • Hooks
  • Term
  • Log
  • Error Codes
  • Actions
  • Definition Shorthand

Advanced Usages

  • Grid Usage
  • Form Persistency
  • Undo & Redo
  • Replay Actions
  • Track Actions
  • Server Validation
  • Entity Templates
  • Folder Structure

React Form

  • Installation
  • Overview
  • Form
  • Field
  • Components
  • Layout
  • Demos

Tools

  • Editor
  • DevTools

More Info

  • Test Cofi
  • Packages
  • Why Cofi?
  • Technologies
  • Videos
  • Channels

Contribute

  • Code of Conduct
  • Contributing Guide
  • Contributors

Arguments

Form class initialized with 3 objects: required model, optional resources and optional settings

import Form from '@cofi/form';

const model = { /*...*/ };
const resources = { /*...*/ };
const settings = { /*...*/ };

const form = new Form();
await form.init(model, resources, settings);

Model is a Json representation of a specific form, and Resources is an object which contains all handlers that model declare of and need during its lifecycle.

Note: There are few reasons why form definition was split into 2 objects such a form persistency, server validation, undo operation, have the ability to easily understand existing form logic, quick development and the ability to create more tools and operations using the model.

Model

Json representation of form. Object contains:

NameTypeDefaultDescription
idstring'form-${x}'A unique id of a form in a page. More info
dataobject{}Data to manipulate by the form which contains fields values. More info
contextobject{}App data that the fields might depend on during the form's lifecycle. More info
fieldsrequired object{}Fields on the form. More info
errorsarray[]Reflects the field's errors in the form. More info
invalidbooleanfalseFlag that reflects if the form is invalid. More info
dirtybooleanfalseFlag that reflects if the form is dirty. More info
processingbooleanfalseFlag that reflects if the form is busy with processing pending actions. More info
pendingActionsarrayfalseReflects form's pending actions to process (for example change value). More info
initializedDataobject{}Reflects form's data after init action done (data might change during it using dependenciesChange handler).
prevDataobject{}Reflects form's data prior to the last action processed.

Resources

Object which contains all handlers that model declare of and need during its lifecycle. Object contains:

NameTypeDefaultDescription
componentsobject{}Contains all components that field uses during the form's lifecycle. More info
validatorsobject{}Contains all field's validators handlers. More info
termsobject{}Contains all field's terms handlers (such as exclude, disable and require terms). More info
conversionsobject{}Contains all field's conversions handlers (used by field's formatters and parsers). More info
dependenciesChangesobject{}Contains all field's dependenciesChange handlers. More info
hooksobject{}Contains form hooks handlers. More info

Settings

Cofi settings overrides. Object contains:

NameTypeDefaultDescription
changeValueDebounceWaitnumber250Debounce ms when calling changeValue action
changeValueDebounceMaxWaitnumber60000Debounce max ms when calling changeValue action
changeStateDebounceWaitnumber250Debounce ms when calling changeState action
changeStateDebounceMaxWaitnumber60000Debounce mac ms when calling changeState action
← OverviewId →
  • Model
  • Resources
  • Settings
cofi
Copyright © 2021 Verizon Media
DOCS
IntroductionForm ClassReact FormReact ComponentsReact Layout
DEMOS
React FormReact ComponentsReact Layout
CONTRIBUTING
Code Of ConductContributing GuideContributorsUsers
CHANNELS
StarGitHubStack OverflowMediumVideos