35 lines
585 B
JavaScript
35 lines
585 B
JavaScript
import { emitEvent } from '../lib/emitters'
|
|
|
|
export default {
|
|
name: 'checkboxinput',
|
|
|
|
props: {
|
|
name: String,
|
|
initialChecked: Boolean,
|
|
},
|
|
|
|
data: function() {
|
|
return {
|
|
isChecked: this.initialChecked,
|
|
}
|
|
},
|
|
|
|
created: function() {
|
|
emitEvent('field-mount', this, {
|
|
optional: this.optional,
|
|
name: this.name,
|
|
valid: this.isChecked,
|
|
})
|
|
},
|
|
|
|
methods: {
|
|
onInput: function(e) {
|
|
emitEvent('field-change', this, {
|
|
value: e.target.checked,
|
|
name: this.name,
|
|
valid: this.isChecked,
|
|
})
|
|
},
|
|
},
|
|
}
|