For Filament 3.x:
If I'm understanding your problem correctly, you're looking for a way to render some infolist content at the top of an Edit page?
I think I've worked this out. Took a bit of digging. But basically an EditRecord page inherits Filament\Pages\BasePage which includes the InteractsWithInfolists trait. Same as a ViewRecord page.
So I took a look at the ViewRecord page to see what it's doing to support infolists. Pretty simple actually, it has 2 extra methods:
public function infolist(Infolist $infolist): Infolist
{
return static::getResource()::infolist($infolist);
}
protected function makeInfolist(): Infolist
{
return parent::makeInfolist()
->record($this->getRecord())
->columns($this->hasInlineLabels() ? 1 : 2)
->inlineLabel($this->hasInlineLabels());
}
So, the first thing to do would be to add these two methods (and import Infolist) to your Edit{Something}.php page.
For me, I'm using EditQuote.php coz I have a quoting system.
// ...
use Filament\Infolists\Infolist;
// ...
class EditQuote extends EditRecord
{
// ....
public function infolist(Infolist $infolist): Infolist
{
return static::getResource()::infolist($infolist);
}
protected function makeInfolist(): Infolist
{
return parent::makeInfolist()
->record($this->getRecord())
->columns($this->hasInlineLabels() ? 1 : 2)
->inlineLabel($this->hasInlineLabels());
}
// ....
}
With the infolist() method, you can see that by default it's pulling the infolist from the Resource class. You can choose to keep this and build your infolist in the Resource class OR you could override the infolist() method and build your infolist() inside this class.
Now, to render the Infolist, you've got a couple of options.
- Creating a custom view page and copying over all the contents of
resources/views/resources/pages/edit-record.blade.php into your custom view and then rendering it. By copying over all the contents of edit-record.blade.php you're making sure that the edit page functionality continues to work as expected:
/path/to/your/custom-view.blade.php
<x-filament-panels::page
@class([
'fi-resource-edit-record-page',
'fi-resource-' . str_replace('/', '-', $this->getResource()::getSlug()),
'fi-resource-record-' . $record->getKey(),
])
>
// Render the infolist
{{ $this->infolist }}
@capture($form)
<x-filament-panels::form
id="form"
:wire:key="$this->getId() . '.forms.' . $this->getFormStatePath()"
wire:submit="save"
>
{{ $this->form }}
<x-filament-panels::form.actions
:actions="$this->getCachedFormActions()"
:full-width="$this->hasFullWidthFormActions()"
/>
</x-filament-panels::form>
@endcapture
@php
$relationManagers = $this->getRelationManagers();
$hasCombinedRelationManagerTabsWithContent = $this->hasCombinedRelationManagerTabsWithContent();
@endphp
@if ((! $hasCombinedRelationManagerTabsWithContent) || (! count($relationManagers)))
{{ $form() }}
@endif
@if (count($relationManagers))
<x-filament-panels::resources.relation-managers
:active-locale="isset($activeLocale) ? $activeLocale : null"
:active-manager="$this->activeRelationManager ?? ($hasCombinedRelationManagerTabsWithContent ? null : array_key_first($relationManagers))"
:content-tab-label="$this->getContentTabLabel()"
:content-tab-icon="$this->getContentTabIcon()"
:content-tab-position="$this->getContentTabPosition()"
:managers="$relationManagers"
:owner-record="$record"
:page-class="static::class"
>
@if ($hasCombinedRelationManagerTabsWithContent)
<x-slot name="content">
{{ $form() }}
</x-slot>
@endif
</x-filament-panels::resources.relation-managers>
@endif
<x-filament-panels::page.unsaved-data-changes-alert />
</x-filament-panels::page>
- Publish the filament view files (not always recommended) and then just add {{ $this->infolist }} to the edit-record.blade.php (pretty much the same as the above).
https://filamentphp.com/docs/3.x/support/style-customization#publishing-blade-views
Optional:
Create your own EditRecord class that extends Filament's EditRecord and add the above Infolist methods so and update all your Edit{Something}.php pages to extend your new EditRecord class. That way all your Edit pages will inherit the Infolist functionality.