F
Filamentβ€’8mo ago
_Lietze

Fill Select on relationmanager creation form

How can i pre-fill parent relation selector on a create form on a relationmananger? On the Practice View, i have a Patient relationmanager, and when i create a new patient on that page, i want to have already selected the practice, but i'm not sure how I can implement that.
Select::make('practice_id')
->label('Practice')
->helperText(fn (string $operation) => $operation !== 'view' ? 'If the practice you are looking for is not in the list, please make sure it has a filled name.' : '')
->placeholder('Select a practice')
->options(fn () => Practice::all()
->pluck('filled_name', 'id')
->sort(SORT_NATURAL | SORT_FLAG_CASE)
->toArray()
),
Select::make('practice_id')
->label('Practice')
->helperText(fn (string $operation) => $operation !== 'view' ? 'If the practice you are looking for is not in the list, please make sure it has a filled name.' : '')
->placeholder('Select a practice')
->options(fn () => Practice::all()
->pluck('filled_name', 'id')
->sort(SORT_NATURAL | SORT_FLAG_CASE)
->toArray()
),
I tried using afterStateHydrated, but I'm not sure which injections i need to get to get the ID of the practice of which page I'm on right now.
1 Reply
_Lietze
_LietzeOPβ€’8mo ago
This is already done automatically by filament, just remove the select field entirely πŸ˜…
Want results from more Discord servers?
Add your server