Hi,
i found your very usefull library, but unfortunatelly i cant found a way to implement a simple submit button, or prevent the default event.
I use for now a form tag which is wrapping the vue-form-generator component, and inside i create manually a submit button.
But i think it would be cool if we can add a new type "submit" in the schema, but maybe there is reasons if this not exists...
Thanks, and sorry for the mystakes.
Hi,
the reason why there is no submit button, that I'm using this component in my webapps. Where there is no submit, only Save (a json model).
But your request is good, I think, I will add it. :+1:
Hi,
Thanks for your quick answer !
But i still have another question, and i will use this issue to do so !
How can i get the list of the errors of the form in real time ?
Example: I want to add a disabled class to my submit button, and remove it if there is no more errors.
How can i do that ?
I already created a prop in my model, and a v-bind:class="{'disabled': !isValid}".
But how to populate the status of "isValid" prop ?
Hi,
please check this part of example code: https://github.com/icebob/vue-form-generator/blob/master/dev/app.vue#L77
I make a v-ref for the component and watching the this.$refs.form.errors property in a computed prop.
Thanks again for your support and your advises, i finally ended with a custom method and a v-bind attribute like so :
v-bind:disabled="!sendable()"
And in this method i finnally check directly my models :
sendable()
{
return (this.model.email.length > 0
&& this.model.password.length > 0);
}
But i cant use the this.$refs.form.errors.length > 0, because by default the errors are set to 0, because i setted the option "validateAfterLoad", because i dont want the errors appears at start.
With my method, unfortunatelly i only check if the field is empty or not, and not really the result of your validator.
Maybe adding an option like validateAfterSubmit can help ?
What is your opinion on this ?
To get back to the original question, maybe a simple slot named "submit" could be enough ?
No, I will create a fieldSubmit component and it can be add to form via schema.
@Masterchoc I will add a validateBeforeSubmit property to the submit field in the schema. And if you click the submit button, run a validate(). If no errors, call the onClick event in the schema. (This is the plan)
Implemented in #26
Most helpful comment
@Masterchoc I will add a
validateBeforeSubmitproperty to the submit field in the schema. And if you click the submit button, run avalidate(). If no errors, call theonClickevent in the schema. (This is the plan)