Hide Text Form Input based on Selected Data from other Form Components
Hi there I have this codes, and I can't seem to make the expected hidden form behavior. The the other_information text input should show based on the data of the status Radio.
Radio::make('status')
->options([
0 => 'Open',
1 => 'Closed',
2 => 'Done',
])
->default(0)
->required(),
TextInput::make('other_information')
->numeric()
->visible(fn ($get) => $get('./status') < 1),
Does anyone know how to do this? Thanks a bunch.4 Replies
Try adding live() to the 'status'. Also you don't really need the ./, just $get('status').
Okay, Thank you. Trying it now
Thank you @cheesegrits , it seems live() was the missing piece. Thank you!
N/p. Basically, any time you need to run logic in your schema when a field is changed, it needs to be live(). That's the only way Livewire then knows to update, and your schema code gets re-run.
Okay, I'll take note of this one. Thanks a bunch!