mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-26 09:04:28 +00:00
Form Validation
This commit is contained in:
@@ -0,0 +1,40 @@
|
|||||||
|
export default {
|
||||||
|
inject: [
|
||||||
|
'$registerToForm'
|
||||||
|
],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
feedback: {
|
||||||
|
success: [],
|
||||||
|
danger: []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
clearValidation() {
|
||||||
|
this.feedback = {
|
||||||
|
success: [],
|
||||||
|
danger: []
|
||||||
|
};
|
||||||
|
},
|
||||||
|
setFeedback(valid, feedback) {
|
||||||
|
if (!feedback)
|
||||||
|
feedback = [];
|
||||||
|
if (!Array.isArray(feedback))
|
||||||
|
feedback = [feedback];
|
||||||
|
this.feedback[valid ? 'success' : 'danger'] = feedback;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.$registerToForm)
|
||||||
|
this.$registerToForm(this);
|
||||||
|
},
|
||||||
|
template: `
|
||||||
|
<template v-for="(arr, key) in feedback" :key="key">
|
||||||
|
<div v-for="msg in arr" :key="msg" class="alert alert-dismissible fade show" :class="'alert-' + key" role="alert">
|
||||||
|
{{msg}}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
`
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user