Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

npw's avatar
Level 1

Neat way to blank input when x-show is false in Alpine?

Hi guys,

Does anyone have a neat implementation/idea for how to cleanly blank the value of an input control if its x-show value (or display value) is false/block?

Have a lot of controls in a form that can be shown and hidden dynamically depending on values of other inputs. It works nicely using the following type of thing (basic example) with x-show and x-model ('active and active_date are using x-model from their relevant controls):

control to be shown hidden: x-show="active === '1'"

parent control: x-on:change="if(!(active === '1')){ active_date = '' }"

However this obviously becomes a pain when we have multiple controls that reference the same visibility rule, especially when the display rule is based on values from a few different parent controls.

Is there an event that relates to the change in x-show status I can hook into or anything? Or any neat way to sync the two i'm missing?

Thanks, Neil

0 likes
0 replies

Please or to participate in this conversation.