© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•17mo ago•
4 replies
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);
}
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);
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Table searchable isIndividual with drop down values
FilamentFFilament / ❓┊help
3y ago
Dependent selects don't showing selected values in edit form
FilamentFFilament / ❓┊help
2y ago
Select Dependent Form (Edit Page)
FilamentFFilament / ❓┊help
3y ago
Filament Drop-down menu
FilamentFFilament / ❓┊help
3mo ago