question about useFormMetaData #511
Closed
jamalsoueidan
started this conversation in
General
Replies: 1 comment
-
I figure it out, you need to use form.update(), and useField const [, form] = useField(field.name);
const list = field.getFieldList();
const handleChange = useCallback(
(value: string[]) => {
if (value.length === 0) {
return;
}
form.update({
name: field.name,
value: value
.map((locationId) =>
data.find((location) => location._id === locationId),
)
.filter(Boolean)
.map((newLocation) => ({
location: newLocation._id,
locationType: newLocation.locationType,
})),
});
},
[data, field.name, form],
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would have been great if we could somehow get the update, reorder, and remove functionalities for lists etc., without a form, and just from the field somehow.
The way you manipulate a list of objects in an array is not the easiest, because I want to do it through code, not through buttons.
Maybe I'm doing something wrong, but I'm trying to use the Mantine SwitchGroup.
I appreciate any help.
Beta Was this translation helpful? Give feedback.
All reactions