control error display for options input component
This commit is contained in:
dandds
2018-11-08 11:43:29 -05:00
committed by GitHub
3 changed files with 34 additions and 13 deletions

View File

@@ -2,15 +2,33 @@ export default {
name: 'optionsinput',
props: {
name: String
name: String,
initialErrors: {
type: Array,
default: () => []
},
initialValue: String,
},
data: function () {
const showError = (this.initialErrors && this.initialErrors.length) || false
return {
showError: showError,
showValid: !showError && !!this.initialValue,
validationError: this.initialErrors.join(' ')
}
},
methods: {
onInput: function (e) {
this.$root.$emit('field-change', {
value: e.target.value,
name: this.name
})
this.showError = false
this.showValid = true
}
}
}