Custom page with resource record error

I have a custom page:

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()); }

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);
    }

    // ...
}


Code like this worked for us and our demo cases
Was this page helpful?