Skip to content

Adding custom components

Bharat Soni edited this page Dec 6, 2019 · 3 revisions

You can create a new component either from scratch(for some reason) or compose existing fields to create complex form fields. You need to make sure of a few things if you are creating custom fields:

  • Make sure you call addField function provided by Form through the context. The Form can track the field values and validate it only if you register the field using the addField function. You should call addField either before or after rendering, depending on your requirements. Make sure you call setFieldValue in the Form context on value change. This call will update field value in Form state.
  • Please call validateForm function in the context to validate the field. Please note that form submission triggers a full form validation.

Please refer to the Form API details for more details on these functions.

Here is a code sandbox example of a custom component. This demonstrates how to make a custom time-picker component.

Clone this wiki locally