Skip to content

Commit 8d4a33b

Browse files
committed
feat(visibility): dynamic visibility per field
1 parent fcb406a commit 8d4a33b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/FormGroup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const shouldHaveLabel = computed(() => {
4545
</script>
4646

4747
<template>
48-
<div class="form-group">
48+
<div class="form-group" :style="{display: fieldComponent && !fieldComponent.isVisible ? 'none': ''}">
4949
<label v-if="shouldHaveLabel" :for="fieldId">
5050
<span> {{ props.field.label }}</span>
5151
</label>

src/mixins/abstractField.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ export default {
198198
return this.model[this.field.model]
199199
},
200200

201+
/**
202+
* Compute the state of visibility of the field/input component. `this.field.visible` must be set for this to work,
203+
* otherwise this will always return true.
204+
*/
205+
isVisible () {
206+
return this.determineDynamicAttribute('visible', true)
207+
},
208+
201209
/**
202210
* Compute the disabled state of the field/input component. `this.field.disabled` must be set for this to work,
203211
* otherwise this will always return false.

0 commit comments

Comments
 (0)