© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
27 replies
Pasteko

Is there any other way to write this?

Forms\Components\Select::make('year_id')
                ->options(Year::all()->pluck('year', 'id')->toArray())
                ->afterStateHydrated(function ($set, $state, $record) {
                    if (isset($record->product_id)) {
                            $set('year_id', Product::with('year')->where('id',  $record->product_id)->value('year_id'));
                        }
                 })
                ->label('Year')
                ->reactive()
                ->required(),
Forms\Components\Select::make('year_id')
                ->options(Year::all()->pluck('year', 'id')->toArray())
                ->afterStateHydrated(function ($set, $state, $record) {
                    if (isset($record->product_id)) {
                            $set('year_id', Product::with('year')->where('id',  $record->product_id)->value('year_id'));
                        }
                 })
                ->label('Year')
                ->reactive()
                ->required(),
`
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

is there any way to modify this message?
FilamentFFilament / ❓┊help
3y ago
Is there a better way to write this x-init?
FilamentFFilament / ❓┊help
16mo ago
Is there any way to Refresh Summarizer?
FilamentFFilament / ❓┊help
11mo ago
is there any way to filter by tag ?
FilamentFFilament / ❓┊help
3y ago