F
Filament5mo ago
Damien

How do I disable the text inputs base on whether or not a checkbox is checked?

I have looked at the docs for using the state of another component, Get $get for example however I do not seem to be able to find the correct way of doing what I would like to. Does someone mind pointing me in the write direction? I've attached a screenshot and some code below:
Section::make('Other Costs')
->schema([
Checkbox::make('london-waiting')
->label('London Waiting')
->columnSpan(6),
Checkbox::make('fuel-&-accommodation')
->label('Fuel & Accommodation')
->columnSpan(6),
Checkbox::make('system-commissioning')
->label('System Commissioning')
->columnSpan(6),
TextInput::make('delivery-costs')
->placeholder('0')
->label('Delivery Costs (GBP)')
->prefix('£')
->integer()
->columnSpan(2),
TextInput::make('london-waiting-number-of-days')
->placeholder('0')
->label('London Waiting Number of Days')
->integer()
->columnSpan(2),
TextInput::make('fuel-&-accommodation-number-of-days')
->placeholder('0')
->label('Fuel & Accommodation Number of Days')
->integer()
->columnSpan(2),
])
->columnSpan(6)
->columns(6)
->compact(),
Section::make('Other Costs')
->schema([
Checkbox::make('london-waiting')
->label('London Waiting')
->columnSpan(6),
Checkbox::make('fuel-&-accommodation')
->label('Fuel & Accommodation')
->columnSpan(6),
Checkbox::make('system-commissioning')
->label('System Commissioning')
->columnSpan(6),
TextInput::make('delivery-costs')
->placeholder('0')
->label('Delivery Costs (GBP)')
->prefix('£')
->integer()
->columnSpan(2),
TextInput::make('london-waiting-number-of-days')
->placeholder('0')
->label('London Waiting Number of Days')
->integer()
->columnSpan(2),
TextInput::make('fuel-&-accommodation-number-of-days')
->placeholder('0')
->label('Fuel & Accommodation Number of Days')
->integer()
->columnSpan(2),
])
->columnSpan(6)
->columns(6)
->compact(),
No description
3 Replies
Damien
Damien5mo ago
For example, from the docs, if I add ->hidden(fn (Get $get) => $get('london-waiting') === false), I would expect me checking the box to then show the additional input however it does nothing.
awcodes
awcodes5mo ago
Make sure you make London-waiting ->live()
Damien
Damien5mo ago
ah perfect, thanks @awcodes !