Form
View Source
:
Props
(props: {
editButtonProps: ButtonProps
getFieldProps: (
id: keyof Payload,
getChangeValue?: (event: ChangeEvent<HTMLInputElement>) => any
) => Record<string, any>
isEditing: boolean
isSubmitting: boolean
payload: Payload
}) => ReactNodeisEditing
Toggled by trigger or focusing/blurring a field.
isSubmitting
True when a submit action occurs either from the enter key or
blurring the form with different data from initialPayload.
editButtonProps
Provides the proper props and callbacks to toggle editing mode and show a spinner when submitting. Must be passed to a Button component.
getFieldProps
Accepts an id as the first argument that maps to the respective
field key in initialPayload. It also receives a getChangeValue
function as the second argument used to resolve the value when
dealing with non traditional events like Select or NumberField.
PayloadThe initial data to seed the form with. Used to determine
previous state when a cancel action occurs as well as if the
form should submit or not. This can be passed new data
(like updating from onSubmit). Use a simple data structure
to avoid false positives when the previous and initial payload
are compared to determine calling onSubmit.
(payload: Payload, complete: () => void) => voidCalled whenever a submit action occurs (enter key / form blur)
and the form has a different internal payload compared to
the initialPayload.
payload
The newly edited payload that should be submitted.
complete
Call whenever the form is done completing to re-enable the form.