Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

normykinz's avatar

Is is possible to "watch" for changes when using the form helper?

Is this possible? I'm using watch(form.type, (value) => ..... but it's not pickung up on any changes because at face value, form.type is not a ref.

Can't find anything in the documenation about it, so I'm wondering if this is a thing right now.

1 like
8 replies
jorisvanandel's avatar

@normykinz That's a shame. I have the exact same problem but my form is quite big and adding a @change event to every form element does not sound ideal.

pallade's avatar

I found that this seems to work:

watch(
  () => form.exampleField,
  (exampleField, prevExampleField) => {
    /* ... */
  }
)

More info: vuejs.org api reactivity-core.html#watch

1 like
x4afe3's avatar

watching the form.isDirty flag works for detecting the first change to a form:

watch(
    ()=>form.isDirty, 
    () => {
	     //react to first changes
    })
})
mrleblanc101's avatar

You can't watch a reactive object directly, you need to use a reactive getter. This worked for me:

watch(
    () => form,
    () => {
        something();
    },
    { deep: true },
);

Please or to participate in this conversation.