How to reset meta?
See original GitHub issueHey, I see you have been working very hard on the releases for your new version, I really like it, and it’s working great so far on everything I have used it on, even though it’s in alpha. I have also now fixed all the meta tags after you have changed the meta API, also works great. 😎
I have really only one remaining question, and its how to “reset” a form programmatically from within onSubmit
. I need to reset the meta fields once they submit. I want ‘dirty’ to go back to false so they have to make another fresh change before submit re-enables, errors re-appear, etc.
What would be the best way to accomplish this? Even with a nested form I don’t see how I can use it inside onSubmit
<v-form v-slot="{ meta }" :validation-schema="validationSchema" @submit="onSubmit">
<base-input v-model="password.password" validation-key="password" type="password" label="Password" />
<base-input v-model="password.password_confirmation" validation-key="password_confirmation" type="password" label="Confirm Password" />
<base-button :loading="submitting" :disabled="!meta.dirty || !meta.valid">Save Changes</base-button>
</v-form>
<script>
import { Form as VForm } from 'vee-validate';
export default {
components: {
VForm,
},
data() {
return {
password: {},
submitting: false,
validationSchema: object({
password: string().min(8).required().label('Password'),
password_confirmation: string().required().oneOf([ref('password')], 'Passwords do not match').label('Password confirmation'),
}),
};
},
methods: {
async onSubmit() {
this.submitting = true;
await Promise.all([
api.patch('self/password', this.password),
]);
this.password = {};
// <------------------------ RESET FORM HERE
this.submitting = false;
},
},
};
</script>
Issue Analytics
- State:
- Created 3 years ago
- Comments:21 (8 by maintainers)
Top Results From Across the Web
How to Factory Reset the Meta (Oculus) Quest or Quest 2
Headset: Press and hold the power and volume down buttons and select factory reset from the USB Update Mode menu. · Meta Quest...
Read more >How to factory reset your Meta Quest 2 to fix problems or wipe
Firstly open the Meta Quest app on your smartphone · Then click the menu button on the bottom right · Then tap on...
Read more >How to Reset Oculus Quest 2 - Online Tech Tips
Tap Factory Reset. A warning screen appears, alerting you that Oculus will delete all information saved on the headset. If you're sure you...
Read more >How To Factory Reset A Meta (Oculus) Quest Or Quest 2
Access the Meta Quest app on an Android or iOS device. · Select Devices, and then choose the connected headset, Quest or Quest...
Read more >How to Factory Reset a Oculus Quest 2 Headset - wikiHow
1. Power off your Quest 2. To power off your Quest 2 headset, press and hold the Power button until the power menu...
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 Free
Top 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
To provide some context, I ran into the opposite case in
v3
. There was a “silent validation” running after each reset to make sure thevalid
state is correct. That seemed to work fine, but that meant that forms that are empty initially are automatically invalid which depending on what you do in the UI might be aggressive for your users. So it’s like you can only pick one state or the other but you can’t havevalid
correct on both occasions.There are various functions on the slot prop that you can use to set the
dirty
andtouched
flags.https://vee-validate.logaretm.com/v4/api/form#-setfielddirty:-(field:-string,-isdirty:-boolean)-=>-void-
That has been always the case, the form is invalid because the
valid
prop for the second field has not been verified yet.The only difference from your example to upgrade to the latest is the submit function:
Also the form can never be submitted while invalid, this is because vee-validate revalidates everything before submitting the form, even if it was already valid.