F
Filament3mo ago
slamx_

IconColumn display error v3

If you try to map a JSON table value using IconColumn, the icon is mapped/displayed x-fold (per array item) if values are available.
No description
11 Replies
slamx_
slamx_3mo ago
any ideas?
Vp
Vp3mo ago
maybe your code
slamx_
slamx_3mo ago
IconColumn::make('allowed_user_ids') ->label(__('Users')) ->toggleable() ->icon(fn (string $state): string => match ($state) { '' => 'heroicon-o-minus', default => 'heroicon-o-user-group' })
Vp
Vp3mo ago
Based on your code what you receive/display in tables were correct.
slamx_
slamx_3mo ago
ok - but allowed_user_ids is ja JSON Field, why they output not only one icon then? and you see also that a empty state don't return a minus icon
Vp
Vp3mo ago
What are you trying to do? if allowed_user_ids is not null then display "user-group" otherwise "minus"?
slamx_
slamx_3mo ago
right, but in V2 they show only one user-group icon and a minus if the value is empty, now they show x-icons based on the array length @Dan Harrin Could it be that JSON (array cast fields) might need a special parameter, in v2 it was displayed normally?
Dan Harrin
Dan Harrin3mo ago
"normal" IMO is what we have in v3 otherwise JSON is not supported at all you can use getStateUsing() to transform the allowed_user_ids into another value which you can use in the icon OR you can get the $record in icon() and decide the icon based on that instead of the raw state
slamx_
slamx_3mo ago
I haven't found anything about getStateUsing in the docs - is there an alternative to the doc to solve such problems myself?
Dan Harrin
Dan Harrin3mo ago
just an alias for this method