IconColumn no response

IconColumn::make('short_content')
->label('Short Content')
->options([
'heroicon-o-check-circle' => function ($record): bool {
ray([$record->short_version, $record->short_doc]);
return isset($record->short_version) || $record->short_doc;
},
])
->colors([
'success' => function ($record): bool {
ray([$record->short_version, $record->short_doc]);
return isset($record->short_version) }} $record->short_doc;
},
]),
IconColumn::make('short_content')
->label('Short Content')
->options([
'heroicon-o-check-circle' => function ($record): bool {
ray([$record->short_version, $record->short_doc]);
return isset($record->short_version) || $record->short_doc;
},
])
->colors([
'success' => function ($record): bool {
ray([$record->short_version, $record->short_doc]);
return isset($record->short_version) }} $record->short_doc;
},
]),
. Not getting any icons showing or ray() output. What am i missing? Ive tried adding a null for default if thats needed as i dont want an icon if false, but no difference. I know im missing something simple per usual.
6 Replies
Dennis Koch
Dennis Koch2y ago
You need the Closure as the argument and return the array from that. Not the closure as a value. ->options(fn ($record) => [...])
Mark Chaney
Mark ChaneyOP2y ago
@Dennis Koch ah, i was going off the docs @Dennis Koch they so something like
->options([
'heroicon-o-x-circle',
'heroicon-o-pencil' => fn ($state, $record): bool => $record->status === 2,
'heroicon-o-clock' => fn ($state): bool => $state === 'reviewing',
'heroicon-o-check-circle' => fn ($state): bool => $state === 'published',
])
->options([
'heroicon-o-x-circle',
'heroicon-o-pencil' => fn ($state, $record): bool => $record->status === 2,
'heroicon-o-clock' => fn ($state): bool => $state === 'reviewing',
'heroicon-o-check-circle' => fn ($state): bool => $state === 'published',
])
Dennis Koch
Dennis Koch2y ago
Hm, might even work for a IconColumn then. Did you check the HTML if there is really no icon?
Mark Chaney
Mark ChaneyOP2y ago
idk why, but i had to use getStateUsing() and then check $state within options. really weird. oh well
Andrew Wallo
Andrew Wallo2y ago
I don't think the options method works with bool return type. I had the same issue yesterday when trying to use bool for a Select component's options. Using '1' for true and '0' for false worked though. Although this could just be a different issue but idk.
Dan Harrin
Dan Harrin2y ago
@mark_chaney i wouldnt use options() ->icon(fn ($record) => return single string, not array)
Want results from more Discord servers?
Add your server