Creating a field list with an initial entry #716
-
I'm making a form with an array that requires at least one item, so I'd like to automatically create an initial entry before rendering the component. I attempted to use const slots = fields.slots.getFieldList();
if (slots.length === 0) {
form.insert({ name: fields.slots.name });
} When I added a check for How can I add an initial item to a field list? |
Beta Was this translation helpful? Give feedback.
Answered by
marcomuser
Jul 24, 2024
Replies: 1 comment 1 reply
-
I would add the initial array entry as part of the defaultValue you pass to the useForm hook. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
skycoop
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would add the initial array entry as part of the defaultValue you pass to the useForm hook.