'this.form.clearErrors()' returns error
See original GitHub issueVersions:
@inertiajs/inertia
version: 0.8.4@inertiajs/inertia-vue
version: 0.5.5@inertiajs/inertia-vue3
version: 0.2.3@inertiajs/inertia-react
version: -@inertiajs/inertia-svelte
version: -
Describe the problem:
Context:
The form is initialized like so:
data () {
return {
form: this.$inertia.form({
'_method': 'PUT',
name: '',
}, {
bag: 'updateDivisionForm'
}),
}
},
The problem:
Whenever I call this.form.clearErrors()
the errors are not cleared and the console returns an error:
I have already ran yarn upgarde --latest
.
Steps to reproduce:
- Create the form using
form: this.$inertia.form({...})
with errorbag (like in example above) - Submit the form using
this.form.post()
- (optional) Have the server return a validation error
- Call
this.form.clearErrors()
Did I miss something? I used these docs as guide
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
useForm - ClearErrors - React Hook Form
This function can manually clear errors in the form. Props. Type, Description, Example. undefined, Remove all errors. clearErrors().
Read more >React Hook Form - Set Error / Clear Error - CodeSandbox
VS Code's tsserver was deleted by another application such as a misbehaving virus detection tool. Please reinstall VS Code. Manage Extension.
Read more >public function FormState::clearErrors - Drupal 8.2.x
Clears all errors against all form elements made by self::setErrorByName(). Overrides FormStateInterface::clearErrors. File. core/lib/Drupal/Core/Form/FormState ...
Read more >Blog - New in Symfony 4.2: Clear form errors
Symfony 4.2 adds a new clearErrors() method to allow you remove errors after the form has been validated.
Read more >How to clear errors object in vee-validate? - vue.js
I have come up with another solution that could help. in your input we'll add another listener so it will be like this:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@claudiodekker Good observation!
The application I’m working on was originally a laravel jetstream project but we decided to replace jetstream with just inertia and vuetify. I did now know the jetstream package was overwriting the default inertia forms. I uninstalled the jetstream package (since this was still installed and enabled 🤦). And converted the forms as you suggested and that fixed my issue!
Hooray! Now I can use it! Thanks for the quick response!
Hi @TimVanHerwijnen,
Are you sure you don’t have
jetstream-js
installed into yourpackage.json
& JS assets by any chance? This was something that was automatically being used in Laravel Jetstream 1.x, but was removed entirely in Laravel Jetstream 2.x in favor of the form helper that ships with Inertia out of the box nowadays.Assuming this is the case, this perfectly explains why you’re seeing the error that you do: When Jetstream 1.x shipped and Inertia didn’t have a form helper of it’s own,
jetstream-js
“patched” aform
method onto the$inertia
object, and while this was great for Jetstream & Inertia users at the time, it now also causes the natively supported/documented Inertia form helper (the one you’re clearly trying to use) to be overwritten.The reason for this question / assumption has to do with the way I’m seeing you define your form helper. The following two lines were only used with
jetstream-js
’s form helper, and don’t actually do anything with Inertia’s native form helper:Anyway, removing this
jetstream-js
dependency and migrating to Inertia’s form helper shouldn’t be too difficult for any of the existing (jetstream)$inertia.form
’s you might have, as the API’s are very similar.Hope this helps! 👍