diff --git a/assets/controllers/select_toggle_controller.js b/assets/controllers/select_toggle_controller.js index 5ef3814..f306867 100644 --- a/assets/controllers/select_toggle_controller.js +++ b/assets/controllers/select_toggle_controller.js @@ -4,18 +4,21 @@ export default class extends Controller { static classes = [ 'hidden' ] static targets = [ 'container' ] - static values = { show: Array } + static values = { show: Array, visible: Boolean } toggle(event) { let fieldType = event.target.type let formValue = event.target.value let showContainer if ('checkbox' !== fieldType && 'radio' !== fieldType) { - showContainer = this.showValue.indexOf(formValue) !== -1 + this.visibleValue = this.showValue.indexOf(formValue) !== -1 } else { let toggleValue = event.target.dataset.selectToggleValue - showContainer = true === event.target.checked && this.showValue.includes(toggleValue) + this.visibleValue = true === event.target.checked && this.showValue.includes(toggleValue) } - this.containerTarget.classList.toggle(this.hiddenClass, false === showContainer) + } + + visibleValueChanged(visible) { + this.containerTarget.classList.toggle(this.hiddenClass, false === visible) } } diff --git a/templates/booking/edit.html.twig b/templates/booking/edit.html.twig index 735539a..6f8f69e 100644 --- a/templates/booking/edit.html.twig +++ b/templates/booking/edit.html.twig @@ -130,7 +130,7 @@