conditional table column
Hello i'm trying to make a conditional column..
I've follow this online tutorial to make a settings page https://blog.moonguard.dev/setting-page-with-filament
I've made some change to accept media (I'm using curator plugin) and what i want to achieve is a conditional column
If the type of my setting is media i want a CuratorColumn. For everything else a TextColumn but i don't know how to make this
Create a Simple Settings Page with Filament | MoonGuard - Web Monit...
Learn how to create custom settings page with Filament, from generating migrations to dynamically building the edit form.
Solution:Jump to solution
I've finally opted for the custom view because I don't necessarily need a curatorColumn
SettingsResource.php
```php
return $table...
8 Replies
Or maybe it's not possible?
Not possible.
A workaround might be to create a custom Curator column, and have it display its media if relevant, else display your custom TextColumn output. Basically your custom column would be a hybrid of both the other columns. Might not make sense for sortable/searchable on it though.
Thanks for this workaround i will dig into it
I’m doing this exact thing with a custom curator column where I display the curator image if it’s available and if not I display the records initials. Both are wrapped in a circle. So I see either the avatar image or the initials depending on what’s available.
Solution
I've finally opted for the custom view because I don't necessarily need a curatorColumn
SettingsResource.php
settingColumn.blade.php
I had a similar use case where I only wanted to display a column for super_admin users, and hide it for ordinary users.
I simply stored the columns in an array variable, then conditionally appended to the array if the user was super_admin.
Hope that helps someone.
Right, but that's a global thing, you are either showing a column or not, depending on some condition. What OP wanted to do was, in the same column, show different column types depending on some condition. So on some rows show a Curator cell, on other rows show a TextColumn cell, within the same column.