Passing data to custom pages

Hi everyone!
I need to build something like a custom resource, but using pages. It's a little more complicated, but imagine a model User that I display in a table first, with clickable entries that lead me to the corresponding EditPage and the prefilled form. So basically regular resource behavior. I managed to build the table and have the rows clickable with ->recordUrl(fn(User $record) => route('filament.admin.pages.user-edit', ['record' => $record->id])) but I struggle with the form.

So my questions are:

  • Is that the correct way of making the row clickable and passing the record?
  • How do I set up the Edit Page correctly? Meaning getting the passed $record data and prefilling the form?
My current approach for the EditPage (based on ChatGPT) is:

class RegistrationReviewEdit extends Page implements HasForms
{
    use InteractsWithForms;
    public ?User $record = null;

    public ?array $data = [];
    protected static ?string $navigationIcon = 'heroicon-o-document-text';

    protected static string $view = 'filament.pages.user-edit';

    public function mount(User $record): void
    {
        $this->record = User->find($record);
        $this->form->fill([
            'first_name' => $this->record->first_name,
            'last_name' => $this->record->last_name,
            'email' => $this->record->email,
        ]);
    }

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                ...
            ]);
    }
}


This doesn't work though. I think I need to update the route so it accepts parameters, php artisan route:list tells me, that unlike the regular resources, the route for my Edit Page doesn't accept a parameter. But I also don't know how to get this parameter inside the page.

I'm still kinda new to Laravel and Filament and I feel like I'm missing some basic knowledge, that I struggle to find in the docs. Where can I find these info in docs? Are there any tutorials to this specific topic?
Was this page helpful?