F
Filament2mo ago
98.dev

Add button at group level

Is there a way in filament, to add a button at group level, rather than record level? For example, something like this (See screenshot).. Note: That is an edited image.
No description
4 Replies
Dennis Koch
Dennis Koch2mo ago
Nope. I don't think so
98.dev
98.devOP2mo ago
Haha okay
Kenneth Sese
Kenneth Sese2mo ago
@98.dev I just did this recently by tapping into getDescriptionFromRecordUsing():
->groups([
Group::make('section_no')
->label('')
->getTitleFromRecordUsing(function (InspectionItem $record) {
return $record->formItem?->section;
})
->getDescriptionFromRecordUsing(function (InspectionItem $record) {
return new HtmlString(Blade::render(<<<'BLADE'
<x-filament::button
size="xs"
color="success"
outlined
icon="heroicon-o-check-circle"
wire:click.prevent="passStandard('{{ $roomId }}', '{{ $standardId }}')"
wire:key="pass-standard-{{ $roomId }}-{{ $standardId }}"
>
Pass
</x-filament::button>
BLADE, [
'roomId' => $record->inspection_item_section_id,
'standardId' => $record->section_no,
]));
})

])
->groups([
Group::make('section_no')
->label('')
->getTitleFromRecordUsing(function (InspectionItem $record) {
return $record->formItem?->section;
})
->getDescriptionFromRecordUsing(function (InspectionItem $record) {
return new HtmlString(Blade::render(<<<'BLADE'
<x-filament::button
size="xs"
color="success"
outlined
icon="heroicon-o-check-circle"
wire:click.prevent="passStandard('{{ $roomId }}', '{{ $standardId }}')"
wire:key="pass-standard-{{ $roomId }}-{{ $standardId }}"
>
Pass
</x-filament::button>
BLADE, [
'roomId' => $record->inspection_item_section_id,
'standardId' => $record->section_no,
]));
})

])
That was v3 BTW, but probably similiar/same in v4
98.dev
98.devOP2mo ago
Thank you @Kenneth Sese, I'll give that a try

Did you find this page helpful?