How to pass parameters from ListRecords to CreateRecord in Resources?

I have the following relations Menus > Categories > Products. I have ListProducts where I do allow user to choose a Menu from a dropdown and picked menu_id is saved via a $queryString. So now when I click on a Create action I would like to carry this menu_id to the Create page and display related Categories to the user when creating + keeping him in the same Menu. Any best practices on of how to achieve this in Filament?

class ListProducts extends ListRecords
{
    protected static string $resource = ProductResource::class;

    public Collection $menus;

    public ?int $menu = null;

    protected $queryString = [
        'menu'
    ];
    public function mount(): void
    {
        parent::mount();

        $this->menus = Menu::with('products')->get();
    }

    protected function getActions(): array
    {
        return [
            Actions\SelectAction::make('menu')
                ->options($this->menus->pluck('title', 'id')->toArray()),

            Actions\CreateAction::make(),
        ];
    }

    .....
Was this page helpful?