FilamentF
Filament3y 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')),
Was this page helpful?