Filament v3 error with TextColumn
austincarpenter opened this issue · 2 comments
With v3, a TextColumn
can render badges. This can be multiple badges in the one cell if the state of the column is an array
or Collection
.
In my case, I have Tag
models, with a name and colour attribute.
The following works in the resource table but not when exporting:
Tables\Columns\TextColumn::make('tags')
->badge()
->formatStateUsing(fn (Tag $state) => $state->name)
->color(fn (Tag $state) => $state->color->getColor())
The reason is because the column's formatState()
method (and therefore formatStateUsing()
for me) gets called, supplying the Model
, not the Collection
. This is due to the @foreach
loop inside text-column.blade.php
of Filament:
Not sure the best approach to take here, because not all columns have this array-wrapping behaviour, only TextColumns
. In this package, the type of column is not a property of pxlrbt\FilamentExcel\Columns\Column
and therefore a conditional check for the type of column (if originating from the table) is not possible.
@pxlrbt what approach would you like to take here (if at all)? Happy to attempt a PR. 😀
Hm, not sure why this is still an issue. Should this be handled by this part:
filament-excel/src/Exports/Concerns/WithMapping.php
Lines 99 to 110 in ccba226