F
Filament9mo ago
keyduc

dependant selects cannot be searchable ?

Looking best way.. #searchable
2 Replies
LeandroFerreira
LeandroFerreira9mo ago
what is the issue?
keyduc
keyducOP9mo ago
Forms\Components\Select::make('variant_id')->relationship('productVariant') ->label('Select Variant') ->options(function (Get $get) { $variantOptions = $get('variant_options'); return $variantOptions ? $variantOptions : []; }) ->searchable() ->getSearchResultsUsing(fn (Get $get): array => $get('variant_options') ?? []) ->reactive() ->afterStateUpdated(function (Get $get, Set $set, $state) { if ($state) { $variant = ProductVariant::find($state); if ($variant) { $set('price', $variant->price * $get('quantity')); } } }) ->disabled(fn (callable $get) => empty($get('variant_options'))) ->required(), Only work when I remove ->searchable() Parent select here: Forms\Components\Select::make('product_id') ->label('Select Product') ->options(Product::all()->pluck('name', 'id')->toArray()) ->reactive() ->searchable() ->preload() ->afterStateUpdated(function (callable $set, $state) { $variants = ProductVariant::where('product_id', $state)->get(); if ($variants->isEmpty()) { $set('variant_options', []); } else { $set('variant_options', $variants->pluck('sku', 'id')->toArray()); } }) ->required(),
Want results from more Discord servers?
Add your server