© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•14mo ago•
20 replies
Rick Doetinchem

Custom page with resource record error

I have a custom page:

    public static function getPages(): array
    {
        return [
            'ticketWithComments' => Pages\TicketWithComments::route('/{ticketId}/ticketwithcomments'),
…
        ];
    } 
    public static function getPages(): array
    {
        return [
            'ticketWithComments' => Pages\TicketWithComments::route('/{ticketId}/ticketwithcomments'),
…
        ];
    } 


And I try to pickup the ticketId and fill the form with the following code:

    public function mount($ticketId): void
    {
        $this->ticket = Ticket::findOrFail($ticketId);

        $this->form->fill($this->ticket->attributesToArray());
    }
    public function mount($ticketId): void
    {
        $this->ticket = Ticket::findOrFail($ticketId);

        $this->form->fill($this->ticket->attributesToArray());
    }


But I’m getting error: Typed property App\Filament\App\Resources\TicketResource\Pages\TicketWithComments::$ticket must not be accessed before initialization

What am I doing wrong?
Solution
use Filament\Resources\Pages\Page;
use Filament\Resources\Pages\Concerns\InteractsWithRecord;

class ManageUser extends Page
{
    use InteractsWithRecord;
    
    public function mount(int | string $record): void
    {
        $this->record = $this->resolveRecord($record);
    }

    // ...
}
use Filament\Resources\Pages\Page;
use Filament\Resources\Pages\Concerns\InteractsWithRecord;

class ManageUser extends Page
{
    use InteractsWithRecord;
    
    public function mount(int | string $record): void
    {
        $this->record = $this->resolveRecord($record);
    }

    // ...
}


Code like this worked for us and our demo cases
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Custom page with record update
FilamentFFilament / ❓┊help
3y ago
Help with custom resource page
FilamentFFilament / ❓┊help
3y ago
Resource, custom page with widgets, how to sent the $record ?
FilamentFFilament / ❓┊help
3y ago
Custom record pass to recordActions of resource page
FilamentFFilament / ❓┊help
4mo ago