F
Filament14mo ago
core

Access model $record issue in Select (pluck)

I am trying the following: I want to select only the related recipe stages according to the recipe_id, this is inside a RecipeResource, inside an IngredientsRelationsManager. ''' ->form(fn (AttachAction $action): array => [ Forms\Components\Select::make('recipe_stage_id') ->placeholder('Select Stage') ->columnSpan(1) ->required() ->options((fn (Recipe $record) => RecipeStage::where('recipe_id', $record->id)->pluck('name', 'id')->toArray())), ...... ''' error: Argument #1 ($record) must be of type App\Models\Recipe, null given,
Solution:
Change options like this inside relation manager
Jump to solution
3 Replies
Solution
Vp
Vp14mo ago
Change options like this inside relation manager
Vp
Vp14mo ago
->options((fn (RelationManager $livewire) => RecipeStage::where('recipe_id', $livewire->ownerRecord->id)->pluck('name', 'id')->toArray()))
->options((fn (RelationManager $livewire) => RecipeStage::where('recipe_id', $livewire->ownerRecord->id)->pluck('name', 'id')->toArray()))
core
coreOP14mo ago
cool! thanks
Want results from more Discord servers?
Add your server