-
Notifications
You must be signed in to change notification settings - Fork 533
Disable submit button #128
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
Comments
The
|
Hmm, not working because the |
I will fix it in the next release. |
Great! I have a workaround for the moment but it quickly becomes ugly i am afraid. |
@pimhooghiemstra the solution & fix is coming with #129 |
If you updated, could you try this solution? {
type:"submit",
buttonText:"Click me to submit",
onSubmit:this.submitForm,
disabled() {
return this.$parent.errors.length != 0;
}
} |
I'll try this tomorrow |
@icebob I copied the code above for the submit button, but unfortunately this gives me an error. If I check the Vue devtools, it doesn't seem there is a parent errors object? Then I tried the disabled() function to just return true, thinking the button would be disabled on page load but that was not the case. Maybe I am missing something? |
Yes, there are some other bugs :) I'm doing a hotfix. |
Done. So, the first problem Other problem, Firstly, run {
type: "submit",
label: "",
buttonText: "Submit form",
onSubmit(model, schema) {
alert("Form submitted!");
},
disabled() {
return this.errors.length > 0;
}
} I hope it'll work for you. |
@pimhooghiemstra Working? |
@icebob I had a quick (maybe too quick) look last week and it did not work. However, I'll try again today and will post my results later today. Excuse me for the delay. |
@icebob I had a more rigorous look and now it works indeed, thanks! What took me by surprise is the fact that the styling of the disabled submit button is not different from the not-disabled version, this makes the button clickable even when disabled. Maybe this would be better
} Anyway, I am happy it works now |
I added the same css style to form generator when fixed the issue: https://github.com/icebob/vue-form-generator/blob/master/src/formGenerator.vue#L405 I'm glad it is working. I will make a new beta release in a short time. |
I am a bit stuck with the submit button of a form. I would like to disable the submit button when validation fails and enable it again once all fields pass validation.
However, according to the docs we can use the disabled property in the schema for any field and using it on a submit button adds a 'disabled' attribute to the HTML, but on the outer div.form-group. I expected it on the input[type=submit]...
My idea was to use the onValidated callback for an individual field to toggle this enabled/disabled state on the submit button.
Is something like this possible?
Here is a fiddle showing the issue: https://jsfiddle.net/pimhooghiemstra/0mg1v81e/207/
The text was updated successfully, but these errors were encountered: