Add IsDisabled prop to FormToggle component

This commit is contained in:
Bubka 2020-11-16 14:34:58 +01:00
parent b8180e3abf
commit 6aa0134818

View File

@ -2,7 +2,7 @@
<div class="field" :class="{ 'with-offset' : hasOffset }"> <div class="field" :class="{ 'with-offset' : hasOffset }">
<label class="label" v-html="label"></label> <label class="label" v-html="label"></label>
<div class="is-toggle buttons"> <div class="is-toggle buttons">
<a class="button is-dark" v-for="choice in choices" :class="{ 'is-link' : form[fieldName] === choice }" @click="form[fieldName] = choice">{{ choice }}</a> <a class="button is-dark" :disabled="isDisabled" v-for="choice in choices" :class="{ 'is-link' : form[fieldName] === choice }" @click="setField(choice)">{{ choice }}</a>
</div> </div>
<field-error :form="form" :field="fieldName" /> <field-error :form="form" :field="fieldName" />
<p class="help" v-html="help" v-if="help"></p> <p class="help" v-html="help" v-if="help"></p>
@ -49,7 +49,22 @@
hasOffset: { hasOffset: {
type: Boolean, type: Boolean,
default: false default: false
},
isDisabled: {
type: Boolean,
default: false
} }
},
methods: {
setField(value) {
if( !this.isDisabled ) {
this.form[this.fieldName] = value
}
}
} }
} }
</script> </script>