Skip to content

Include UID for emitted form validation events #359

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

Merged
merged 3 commits into from
Jun 27, 2018

Conversation

patcarter883
Copy link

Added a UID to from validation events to allow tracking validation of forms inside of a vue template loop.

Copy link
Member

@zoul0813 zoul0813 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_uid is not a public property exposed by Vue, we can not rely on it.

@@ -307,7 +307,7 @@ div.vue-form-generator(v-if='schema != null')
}

let isValid = this.errors.length == 0;
this.$emit("validated", isValid, this.errors);
this.$emit("validated", isValid, this.errors, this._uid);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're relying on the internal _uid from the Vue component, this property is undocumented and meant for internal use by Vue. If you'd like to implement something like this, then I'd recommend you introduce a stable property and initialize it with a value we can rely on.

@zoul0813
Copy link
Member

Maybe it would make more sense if we returned the VFG instance in the validated event instead of a UID or tracking number. This would allow developers to have access to the entire VFG instance ....

Something like this?

this.$emit('validated', isValid, this.errors, this);

Devs could then use the internal _uid property, or add additional attributes to the VFG tag ... such as :id="someGeneratedId and then access that, they'd also have access to the model and schema in the VFG instance to respond to validated events properly.

@patcarter883
Copy link
Author

Sounds like a plan. Done!!

@lionel-bijaoui lionel-bijaoui merged commit f5f5807 into vue-generators:master Jun 27, 2018
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

Successfully merging this pull request may close these issues.

4 participants