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

hasError doesn't work with bootstrap-vue #14

Open
SlyDave opened this issue Mar 1, 2021 · 1 comment
Open

hasError doesn't work with bootstrap-vue #14

SlyDave opened this issue Mar 1, 2021 · 1 comment

Comments

@SlyDave
Copy link

SlyDave commented Mar 1, 2021

Hi,

Thanks for the package, it's the best stepper I've found so far, with the least bugs.

I'm integrating this with bootstrap-vue, it's form elements have a state prop that requires 3 values, true/false and null. As it can show errors and success.

If I just use the value of :state="!hasError('field')" it will mark the input as valid the moment the component is mounted:
image

the bootstrap-vue b-form-input component expects "state" to return 3 values via return $v.field.$dirty ? !$v.field.$error : null;
true: isValid
false: !isValid
null: not yet validated

I've solved this by adding my own function

inputState(fieldName) {
    if ((fieldName in this.$v.formData)) {
        return this.$v.formData[fieldName].$dirty ? !this.$v.formData[fieldName].$error : null;

    }
  <b-form-input
          id="input-1"
          v-model.trim="formData.email"
          type="email"
          placeholder="Enter email"
          required
          :state="inputState('email')"
  ></b-form-input>

Might be a handy addition to ValidationHelper to provide support for bootstrap-vue 👍

@tushargugnani
Copy link
Owner

Thanks, Gary. I will add this method to the ValidationHelper class in the next release.

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

No branches or pull requests

2 participants