Array Fields Guide
This page is coming soon as part of the documentation restructure.
Learn how to handle dynamic lists of fields and nested arrays with El Form.
Basic Array Fields
const { register, watch, setValue } = useForm({
defaultValues: {
items: [{ name: "", quantity: 1 }],
},
});
const items = watch("items");
const addItem = () => {
setValue("items", [...items, { name: "", quantity: 1 }]);
};
const removeItem = (index) => {
setValue(
"items",
items.filter((_, i) => i !== index)
);
};
Full array fields guide with validation and complex nesting is coming soon.