Replies: 3 comments
-
Encountering the same issue, would like onChange listeners to be triggered when calling @Davit-000 Thanks for the workaround! |
Beta Was this translation helpful? Give feedback.
-
Wanted to chime in here because I also encountered this but with a field array where I was setting the field value on a single field. Example with fix: const Component = () => {
const form = useForm({
defaultValues: {
items: [{ name: "Item 1" }, { name: "Item 2" }],
},
listeners: {
onChange: (state) => console.log("Form changed:", state),
},
});
return (
<form onSubmit={form.handleSubmit}>
<button
onClick={() => {
form.setFieldValue("items[0].name", "Updated Item 1");
}}
>
Update Item 1
</button>
{/* You have to mount the field array for the listener to work */}
<form.Field name="items" mode="array">
{() => <input type="hidden" value={category.id} readOnly />}
</form.Field>
</form>
);
}; |
Beta Was this translation helpful? Give feedback.
-
Heads up that this issue has been resolved here: #1680 and is available in 1.19.4 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to have option to trigger field onChange listener when changing field value by
form.setFieldValue('name', value)
for now it has optiondontUpdateMeta
. The workaround I could find is to dowhich is running filed validation and triggers listener onChange event.
Is this this possible or using the above approach is fine?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions