getTableColumns with conditional columns based on the record/row parents type
Heya, I want to define some columns in a table. I think I need to use the getTableColumns function in my ListSettingValues class. But how can I make these columns conditional, based on the data in the setting value's parent? I want to show a text column for normal values but an image column for uploads. In my EditSettingValue class, I could do this with the getFormSchema method, and then have an if based on the $this->record var.
3 Replies
But maybe this is not possible, as you define the column and not the cell in that column..? Any idea on how to do that? Maybe define a custom column class and have that decide what to become for that record/row?
you'd have to make a custom column for this, i think.
Yeah, I think so too. Got that working π
Just made a new ImageOrTextColumn, and a view which now contains:
@if ($getRecord()->setting->type == 'image')
@include('tables::columns.image-column')
@else
<div>
{{ $getState() }}
</div>
@endif