Field replacement
Replace a field or fieldset value from a button action.
Conform · Pipe
form.update provides an intent for changing a field or form value through a Conform control. Its generated button props support nested/list updates and can clear validation errors.
form.update creates an intent for changing a field or the entire form. Supply the target field name and replacement value through getButtonProps; use the validated option to control whether existing errors are cleared. Inputs must use their field metadata key so React can remount them with the new initial value.
form.update.getButtonProps({ name?, value?, validated? })| Name | Type | Description |
|---|---|---|
name | string | Name of the field to modify; omit it when applying the update to the whole form. |
value | unknown | Replacement value for the selected field or fieldset. |
validated | boolean | Whether the updated target remains validated; set to false to clear all errors. |
Button props for a Conform update intent.
getButtonProps to produce the attributes needed for a button-driven update.<button
{...form.update.getButtonProps({
name: fields.agenda.name,
value: {
title: 'My agenda',
description: 'This is my agenda',
},
})}
>
Update field
</button>A button generated by Conform updates the agenda field, including nested or list fields, when activated.
Replace a field or fieldset value from a button action.
Apply structured data to nested or list fields.
Remove current validation errors while changing form state.
form.update used for?form.update is an intent helper for modifying a field or fieldset. Its button props serialize the target name and replacement value into a form control.
Follow-up: How would you update the entire form? Omit the name option and provide the new form value.
form.update.getButtonProps?Pass name to identify the field and value to provide its replacement value. The documented helper also supports nested and list fields.
Follow-up: How can an update clear all errors? Use the update intent with validated: false and no field name.
The field's metadata key must be assigned to its input. Conform uses that key to notify React to remount the input with the updated initial value.
Follow-up: Why is remounting useful here? It lets the controlled or uncontrolled input receive the new initial value after the intent runs.
form.resetform.validateform.insertform.removeform.reorderuseForm