Repository navigation
Replies: 3 comments
|
Encountering the same issue, would like onChange listeners to be triggered when calling @Davit-000 Thanks for the workaround! |
0 replies
|
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>
);
}; |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
All reactions