opnform/resources/js/components/forms/CheckboxInput.vue

47 lines
968 B
Vue
Raw Normal View History

2022-09-20 19:59:52 +00:00
<template>
2023-12-01 20:24:38 +00:00
<input-wrapper v-bind="inputWrapperProps">
2023-10-28 10:17:50 +00:00
<template #label>
<span />
</template>
2023-12-01 20:24:38 +00:00
<v-checkbox :id="id?id:name" v-model="compVal" :disabled="disabled?true:null" :name="name">
<slot name="label">
{{ label }} <span v-if="required" class="text-red-500 required-dot">*</span>
</slot>
2022-09-20 19:59:52 +00:00
</v-checkbox>
2023-10-28 10:17:50 +00:00
<template #help>
<slot name="help" />
</template>
<template #error>
<slot name="error" />
</template>
</input-wrapper>
2022-09-20 19:59:52 +00:00
</template>
<script>
2023-10-28 10:17:50 +00:00
import { inputProps, useFormInput } from './useFormInput.js'
import VCheckbox from './components/VCheckbox.vue'
2023-10-28 10:17:50 +00:00
import InputWrapper from './components/InputWrapper.vue'
2022-09-20 19:59:52 +00:00
export default {
name: 'CheckboxInput',
2023-10-28 10:17:50 +00:00
components: { InputWrapper, VCheckbox },
props: {
...inputProps
},
setup (props, context) {
return {
2023-12-01 20:24:38 +00:00
...useFormInput(props, context)
2023-10-28 10:17:50 +00:00
}
},
2022-09-20 19:59:52 +00:00
mounted () {
this.compVal = !!this.compVal
}
}
</script>