Get record values in Livewire component with Filament Table

Hello everyone. I have inserted a Filament table inside a Livewire component. One of the fields is of type TextInputColumn, but I would like the same to have the disabled() option at a certain condition, which though depends on the value of the selected record. Can this be done? Unfortunately, I could not find any details about it. Here's my code and my idea:
TextInputColumn::make('name')
->label('Nome del ruolo')
->searchable()
->disabled(
! auth()->role->checkPermission('ruoli-modifica-ruolo-' . $record->slug)
),
TextInputColumn::make('name')
->label('Nome del ruolo')
->searchable()
->disabled(
! auth()->role->checkPermission('ruoli-modifica-ruolo-' . $record->slug)
),
Obviously, for now $record->slug returns an error. Thank you!
2 Replies
awcodes
awcodes14mo ago
You need to use a callback. And you can inject the record there. ->disabled(fn ($record) => $record) Assuming disabled exists on TextInputColumn
Davide Cariola
Davide CariolaOP14mo ago
Thank you so much, I'll try right away! Hi Adam, worked as a charm. Sometimes I forget how versatile Filament is! Thanks for the help. I leave here the solution for others:
TextInputColumn::make('name')
->label('Nome del ruolo')
->searchable()
->disabled(fn(Role $record) => ! auth()->user()->role->checkPermission('ruoli-modifica-ruolo-' . $record->slug)),
TextInputColumn::make('name')
->label('Nome del ruolo')
->searchable()
->disabled(fn(Role $record) => ! auth()->user()->role->checkPermission('ruoli-modifica-ruolo-' . $record->slug)),
Want results from more Discord servers?
Add your server