F
Filament9mo ago
core

dependent select in AttachAction syntax?

I am trying the following: Inside RecipeResource: ProductRelationsManager: ->headerActions([ AttachAction::make() ->modalHeading('Add Product') ->modalDescription('Add Product') ->modalSubmitActionLabel('Add') ->attachAnother(false) ->preloadRecordSelect() ->label('Add Product') ->form(fn (AttachAction $action): array => [ Forms\Components\Select::make('category_id') ->placeholder('Select Product Category') ->searchable() ->columnSpan(1) ->live() ->options($product_categories) ->required(), $action->getRecordSelect(fn (Get $get): Collection => Product::query() ->where('category_id', $get('category_id')) ->pluck('name', 'id')),
Solution:
solved it
Select::make('recordId')
->label('Product')
->options(fn (Get $get): Collection => Product::query()
->where('category_id', $get('category_id'))
->pluck('name', 'id')),
Select::make('recordId')
->label('Product')
->options(fn (Get $get): Collection => Product::query()
->where('category_id', $get('category_id'))
->pluck('name', 'id')),
...
Jump to solution
1 Reply
Solution
core
core9mo ago
solved it
Select::make('recordId')
->label('Product')
->options(fn (Get $get): Collection => Product::query()
->where('category_id', $get('category_id'))
->pluck('name', 'id')),
Select::make('recordId')
->label('Product')
->options(fn (Get $get): Collection => Product::query()
->where('category_id', $get('category_id'))
->pluck('name', 'id')),