2020-10-02 14:17:10 +02:00
|
|
|
<template>
|
|
|
|
<div class="field">
|
2022-03-24 14:58:30 +01:00
|
|
|
<input :id="fieldName" type="checkbox" :name="fieldName" class="is-checkradio is-info" v-model="form[fieldName]" v-on:change="$emit(fieldName, form[fieldName])" v-bind="$attrs">
|
2022-09-21 21:38:53 +02:00
|
|
|
<label tabindex="0" :for="fieldName" class="label" :class="labelClass" v-html="label" v-on:keypress.space.prevent="setCheckbox"></label>
|
2020-10-02 14:17:10 +02:00
|
|
|
<p class="help" v-html="help" v-if="help"></p>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'FormCheckbox',
|
2022-03-24 14:58:30 +01:00
|
|
|
inheritAttrs: false,
|
2020-10-02 14:17:10 +02:00
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
|
2022-09-21 21:50:41 +02:00
|
|
|
labelClass: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
|
2020-10-02 14:17:10 +02:00
|
|
|
fieldName: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
|
|
|
|
form: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
|
|
|
|
help: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
2022-09-21 21:38:53 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
setCheckbox(event) {
|
|
|
|
if (this.$attrs.disabled == false) {
|
|
|
|
this.form[this.fieldName] = !this.form[this.fieldName]
|
|
|
|
this.$emit(this.fieldName, this.form[this.fieldName])
|
|
|
|
}
|
|
|
|
}
|
2020-10-02 14:17:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|