FilamentF
Filament15mo ago
Alan

Edit when dependent drop down shows all values.

On edit when i change the product name the values in drop down has all values irrespective of manufacture until i change manufacture.How to sort this
if ($name === AllAttrib::ATTR_NAME_MANUFACTURER) { $component = Select::make("itemAttrib.$attribId.value") ->label(__($name)) ->options($taskAttrib['value'] ?? []) ->reactive() ->preload() ->live() ->afterStateUpdated(function (callable $get, callable $set) use ($attribId) { $manufacturerId = $get("itemAttrib.$attribId.value"); $set("itemAttrib.product.value", null); // Fetch product options based on selected manufacturer $productOptions = AttribValue::where('parent_id', $manufacturerId) ->orderBy('value') ->pluck('value', 'id') ->toArray(); $set('productOptions', $productOptions); }) ->default($value); } elseif ($name === AllAttrib::ATTR_NAME_PRODUCT_NAME) { $component = Select::make("itemAttrib.$attribId.value") ->label(__($name)) ->options(fn($get) => AttribValue::pluck('value', 'id')->toArray()) // Show all product options ->reactive() ->live() ->preload() ->default($value); } else { $component = Select::make("itemAttrib.$attribId.value") ->label(__($name)) ->options($taskAttrib['value'] ?? []) ->default($value); }
Was this page helpful?