Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access form/field errors within a custom input #57

Closed
quimarche opened this issue Mar 26, 2020 · 4 comments
Closed

Access form/field errors within a custom input #57

quimarche opened this issue Mar 26, 2020 · 4 comments
Labels
feature request New feature or request

Comments

@quimarche
Copy link

I'm trying to enable/disable submit buttons depending on the validation status of other fields in the form. How might I do this? i.e. which property or chain of properties can I access to determine the validation status?

@quimarche quimarche added the feature request New feature or request label Mar 26, 2020
@justin-schroeder
Copy link
Member

Coming Soon

@quimarche Good question, the short answer, is that there isn't a great way to do this at this precise moment, but 2.3 should be coming out soon with elegant support for these kinds of features using scoped slots, and named forms. For that reason I'll close this as a duplicate of #34, but its a solid request.

Current State

That said, it is possible today, just not super "pretty".

<template>
<FormulateForm
  ref="form"
  @input="checkValidation"
>
 ... inputs here ...
  <FormulateInput
    :disabled="hasErrors"
    type="submit"
  />
</FormulateForm>
</template>

<script>
export default {
  data () {
    hasErrors: false
  },
  methods: {
    async checkValidation () {
      // Even better if you debounce this a bit
      this.hasErrors = await this.$refs.form.hasValidationErrors()
    }
  }
}
</script>

Let me know if you have other issues with this.

@fidelix
Copy link

fidelix commented Jul 20, 2020

How would this be done more cleanly in 2.3+ ?

@justin-schroeder
Copy link
Member

@fidelix we pushed the features related to this (originally planned for 2.3/2.4) down the road a bit.

@chrisyeung1121
Copy link

Wonder if it is still developing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants