Skip to main content

Introduction

Oneki.js framework comes with a form management system handling all boilerplate codes and providing some nice features for creating complex performant forms.

The main features are as follows:

  • The form is fully data-driven and values can be updated from outside the form.
  • Simulate bi-directional binding between values and form fields.
  • Support for complex (asynchronous) validations involving more than one field.
  • Support for complex (asynchronous) rules (e.g., update a specific field when you select a value from a drop-down list).

The following diagram shows a simplified architecture of the form system:

Form architecture

Example

Minimal example

export const MyForm = () => {
// useForm expects a "submit" method called when the
// user clicks on the submit button
const { Form } = useForm((values) => console.log(values));

return (
<Form>
<div>
<b>Name: </b>
<Input name="lastname" />
</div>
<button type="submit">Submit</button>
</Form>
);
};

Example with validations

examples/cra-form-basic/src/pages/wrapper.tsx
loading...

Learn more

The following pages describe in detail the form system:

PageDescription
useFormStarting point to create a new form
fieldHow to register a field within a form
Core wrappersHow to use Oneki.js components to wrap standard Form React components to gain performance and avoid having to write boilerplate code.
ValidationsHow to attach validators to a field
Custom wrappersHow to create a custom wrapper around any third party form component
Initial valuesHow to create a form with initial values (create vs edit form)
BindingHow to create a composite value based on the value of one or more field
RulesHow to create a rule for modifying the state of the form
ContextHow to get the form context from underlying components