Repeatable form controls
Render a dynamic array of inputs
Conform · Pipe
getFieldList() returns metadata for every item in an array field. Use the result to render repeatable controls with automatically inferred names and stable keys.
Call getFieldList() on a field's metadata to obtain the metadata objects for its array items. Each returned item provides the generated field name and a stable key for rendering dynamic list controls.
field.getFieldList()An array of field metadata objects for the array field's items.
import { useForm } from '@conform-to/react/future';
export default function TasksForm() {
const { form, fields } = useForm({
defaultValue: { tasks: ['First task'] },
});
const tasks = fields.tasks.getFieldList();
return (
<form {...form.props}>
{tasks.map((task) => (
<input key={task.key} name={task.name} />
))}
</form>
);
}The method returns metadata for each item in the array, allowing the inputs to use generated names and stable keys.
Render a dynamic array of inputs
Build nested repeatable structures
Connect list controls to Conform intents
It returns an array of field metadata objects for an array field. The item names are inferred automatically, so each item can supply its own input name.
Follow-up: How would you support nested arrays? Combine getFieldList() with getFieldset() at the appropriate levels.
Call it on the parent field metadata, such as fields.tasks.getFieldList(). Map over the result and use each item's metadata when rendering the controls.
Follow-up: How can the list be changed? Use the insert, remove, and reorder intents described by Conform.
Each item exposes metadata suitable for rendering, including a generated name and key. The key should identify the rendered item while the name connects the control to the array field.
Follow-up: What problem does automatic name inference solve? It avoids manually constructing names for every array item.
getFieldset()insert intentremove intentreorder intentuseForm