-
Notifications
You must be signed in to change notification settings - Fork 1
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 thecontext
. The Form can track the field values and validate it only if you register the field using theaddField
function. You should calladdField
either before or after rendering, depending on your requirements. Make sure you callsetFieldValue
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.