F
Filament3mo ago
Lucky0

Adding tooltip for each badge in a table column

I couldn't figure out to make this function work. is it possible to do this? what i have so far:
Tables\Columns\TextColumn::make('carFeatures.name')
->badge()
->tooltip(function (Tables\Columns\TextColumn $column, $record): string {
$states = $column->getState();

// dd($record->carFeatures->map(fn($query) => $query->description));

$tooltipContent = [];
if ($states !== null) {
foreach ($states as $state) {
$tooltipContent[] = $state;
}
} else {
$tooltipContent[] = null;
}
return implode(', ', $tooltipContent);
})
->listWithLineBreaks()
->limitList(2)
->expandableLimitedList()
->sortable(),
Tables\Columns\TextColumn::make('carFeatures.name')
->badge()
->tooltip(function (Tables\Columns\TextColumn $column, $record): string {
$states = $column->getState();

// dd($record->carFeatures->map(fn($query) => $query->description));

$tooltipContent = [];
if ($states !== null) {
foreach ($states as $state) {
$tooltipContent[] = $state;
}
} else {
$tooltipContent[] = null;
}
return implode(', ', $tooltipContent);
})
->listWithLineBreaks()
->limitList(2)
->expandableLimitedList()
->sortable(),
currently it will display all the features name when i hover into the feature column. but what i wanted is to display the feature's description for each of the badge if i hover onto them. please guide me.. thank you
1 Reply
krekas
krekas3mo ago
tooltip is for a column, not a badge. you should build a custom column