Add form validation
This commit is contained in:
@@ -108,7 +108,16 @@
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
picker: null,
|
picker: null,
|
||||||
address: {}
|
address: {},
|
||||||
|
requiredFields: [
|
||||||
|
{ field: 'name', label: 'Name' },
|
||||||
|
{ field: 'firstName', label: 'Vorname' },
|
||||||
|
{ field: 'street', label: 'Straße' },
|
||||||
|
{ field: 'zipCode', label: 'PLZ' },
|
||||||
|
{ field: 'city', label: 'Stadt' },
|
||||||
|
{ field: 'country', label: 'Land' },
|
||||||
|
{ field: 'email', label: 'E-Mail' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@@ -136,6 +145,17 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveAddress () {
|
saveAddress () {
|
||||||
|
for (const entry of this.requiredFields)
|
||||||
|
{
|
||||||
|
if (!this.address[entry.field]) {
|
||||||
|
this.$store.commit('alert', {
|
||||||
|
message: 'Bitte das Feld "' + entry.label + '" ausfüllen',
|
||||||
|
class: 'alert-danger'
|
||||||
|
});
|
||||||
|
EventBus.$emit('scrollTo', '#myep-main');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.$store.dispatch('address/save', this.address)
|
this.$store.dispatch('address/save', this.address)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
EventBus.$emit('scrollTo', '#myep-main');
|
EventBus.$emit('scrollTo', '#myep-main');
|
||||||
|
|||||||
Reference in New Issue
Block a user