question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inertia Form `isDirty` attribute not there

See original GitHub issue

Versions:

  • @inertiajs/inertia version: 0.8.7
  • @inertiajs/inertia-vue version: 0.5.12

Describe the problem:

I am using the inertia form helper:

data() {
        return {
            form: this.$inertia.form({
                formData: this.object.fillerData,
                anImage: null,
            })
        }
    }

the form is populated with already existing data from a prop passed to the page because this page is where you update the db records

it also has a file upload section in the form but initially that is just loaded in as a null value

in the vue dev tools the form comes up with the following attributes:

...
errors:Object (empty)
get:ƒ get(e, r)
hasErrors:false
patch:ƒ patch(e, r)
post:ƒ post(e, r)
...

as you can see the form has no isDirty property which is what i would like to use to ensure a change to the form data has occurred before allowing the user to submit the new data to the controller method which will handle it, like so:

<SubmitFormButton v-if="form.isDirty" @click="send" :loading='form.processing' type='submit'>Update {{prop.propName}}</SubmitFormButton>

to reproduce try making a form with pre-filled data from a prop and a null value form section and then see if the form has the isDirty property

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
liam-otcommented, Aug 4, 2021

In case you guys didn’t know, there is no other project which gives as good support as Inertia, at least that I know of

@RobertBoes @reinink Thank you so very much

1reaction
reininkcommented, Aug 4, 2021

The isDirty helper was added in inertia-vue@0.6.0.

You’ll need to update before you can use this. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Forms
When a form has been successfully submitted, the wasSuccessful property will be true . In addition to this, there is also a recentlySuccessful...
Read more >
isDirty is true after submitting and reloading InertiaJS page
When the page reloads, it doesn't seem to reset the Inertia form isDirty state from true to false even when I manually refresh...
Read more >
useForm - setValue
Whether to compute if your entire form is dirty or not against your defaultValues (subscribed to isDirty ). This option will update dirtyFields...
Read more >
Inertia.js forms, modals, and SSR - Jonathan Reinink - YouTube
Inertia.js forms, modals, and SSR - Jonathan Reinink - Laracon Online Summer 2021Jobs in Laravelhttps://larajobs.
Read more >
2:59 PM · May 7, 2021
form helper this morning. This provides a really easy way to show a "there are unsaved form changes" message. Got it working in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found