The new form helper #429
-
Does the new form helper have resetOnSuccess and preserveScroll? I know it was kind of based on the Jetstream form helper which does have those options, but seems the official helper doesn't have these? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, That's correct. Inertia's first-party form does not have Of course, there are exclusions to this, such as a 'change password' form: When the request succeeds, you want to clear any password the user might have entered. For this reason, we have const form = this.$inertia.form({ .. });
form.post('endpoint', {
preserveScroll: true,
onSuccess: () => form.reset('password', 'password_confirmation')
}); As you might already be able to tell from the example above, Hope this helps! |
Beta Was this translation helpful? Give feedback.
Hi,
That's correct. Inertia's first-party form does not have
resetOnSuccess
, as it caused a lot of issues amongst some our users, as well as that we considered it to be a somewhat counter-intuitive feature. Here's why: When an Inertia request finishes, Inertia's state is already updated automatically. Because of this, 'resetting' it on success wouldn't do anything, because the values you've entered are already in the 'target' state!Of course, there are exclusions to this, such as a 'change password' form: When the request succeeds, you want to clear any password the user might have entered. For this reason, we have
this.form.reset()
/this.form.reset(field, field2, ...)
, which you can si…