F
Filamentβ€’2y ago
ehbfa

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
ehbfa
ehbfaOPβ€’2y ago
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?
awcodes
awcodesβ€’2y ago
you'd have to make a custom column for this, i think.
ehbfa
ehbfaOPβ€’2y ago
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
Want results from more Discord servers?
Add your server