In a model, I have 2 specific columns named ‘is_editable
‘ and ‘is_deletable
‘ (both are boolen
). In filament table, while showing record, I want to disable Edit and/or Delete buttons if ‘is_editable
‘ and/or ‘is_deletable
‘ set to false. I don’t know how to do this. Can anybody help me solving this ?
[Please see table picture here](https://i.sstatic.net/8WSrvCTK.png)
Searched Filament document
2
Answers
If $is_editable is false, the button is disabled by adding the disabled attribute. This makes the button unclickable in the browser.If $is_editable is true, the button remains active, meaning it can be clicked. the same logic applied delete button.
<button class="btn edit-btn" @if(!$is_editable) disabled @endif >Edit
<button class="btn delete-btn" @if(!$is_deletable) disabled @endif >Delete
You can use
hidden()
ordisabled()
methods on your table action, and make them dynamic by injecting$record
in the function, like this:Same is for hidden: