Apply a preset value
Replace a field or fieldset with a new object or scalar value.
Conform · Module
Conform's update intent changes a field, including nested or list fields, through an intent button. Pass the target field name and replacement value to form.update.getButtonProps.
The update intent changes a field or fieldset without a normal submit. Configure the button with the target field's metadata name and the replacement value; Conform uses field keys to remount inputs so their initial values reflect the update.
form.update.getButtonProps({ name, value })| Name | Type | Description |
|---|---|---|
name | string | Field metadata name to update; the documented example passes fields.agenda.name. |
value | unknown | Replacement value for the selected field or fieldset. |
The button-props helper returns props for a submit button that dispatches the update intent.
import { useForm } from '@conform-to/react';
export function AgendaForm() {
const [form, fields] = useForm({ id: 'agenda' });
return (
<form id={form.id} method="post">
<input {...fields.agenda.title} />
<button
{...form.update.getButtonProps({
name: fields.agenda.name,
value: { title: 'My agenda' },
})}
>
Update agenda
</button>
</form>
);
}The update intent button replaces the agenda field value with the supplied object.
Replace a field or fieldset with a new object or scalar value.
Refresh nested or list-field inputs after replacing their initial data.
Change values through a button without a conventional form submission.
Use the update intent through form.update.getButtonProps(...), supplying the field metadata name and the replacement value. The button then performs the field update as a form intent rather than an ordinary submission.
Follow-up: How would you update the whole form? Omit name; the update dispatcher treats the missing name as a request to update the entire form.
The button is configured with the field name and a new value. For nested or list fields, the same update mechanism can target the corresponding field metadata.
Follow-up: What must inputs include for the UI to reflect the update? Their field metadata key, because Conform relies on it to trigger React remounting.
Update is one of Conform's form-control intents, alongside reset and list operations such as insert, remove, and reorder. It is exposed through the form's update button helper.
Follow-up: When should a list be manipulated instead? Use insert, remove, or reorder when the operation changes list membership or ordering rather than replacing a field value.
reset intentinsert intentremove intentreorder intentfield metadata keyuseForm