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

nzmattman's avatar

get the form data object

Am i just blind, or can you not get the form data form an inertia form?

I have a simple form like this

  data() {
      form: this.$inertia.form({
        expenses: [],
        partner_expenses: [],
      })
    }
  },

I am wanting to grab that data and check it to see if has changed incase the user clicks away to go elsewhere before saving

I have the code for beforeunload and Inertia.on('before') loaded and working, now I just need to somehow get the data from the form to check to see if it has been updated.

How can I go about doing this?

0 likes
4 replies
Sinnbeck's avatar

It should be available in form. There is also a form.isDirty()

nzmattman's avatar

Thanks @sinnbeck . i tried form.data but that is a function, so can't check with that.

I assume then form.isDirty() will tell me if the fields have changed? ie, if the form is populated on load, and then changed it will be dirty. but if it has not changed after it has been populated, it will be clean?

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@nzmattman I wrongly assumed the data was nested like in react. Seems vue isn't nested so it's just form

Don't think isDirty() shows what was changed. But use console.log() to check

It is mentioned at the bottom of this page https://inertiajs.com/forms

Please or to participate in this conversation.