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.

How to reset meta?

See original GitHub issue

Hey, 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:closed
  • Created 3 years ago
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
logaretmcommented, Oct 19, 2020

To provide some context, I ran into the opposite case in v3. There was a “silent validation” running after each reset to make sure the valid 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 have valid correct on both occasions.

There are various functions on the slot prop that you can use to set the dirty and touched flags.

https://vee-validate.logaretm.com/v4/api/form#-setfielddirty:-(field:-string,-isdirty:-boolean)-=>-void-

0reactions
logaretmcommented, Feb 17, 2021

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:

submitForm(values, actions) {
  alert("FORM SUBMITTED.... now check the input you changed");
  actions.resetForm(); // 👈 no longer nested inside `form`
},

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.

Read more comments on GitHub >

github_iconTop 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 >

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