© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
H.Bilbao

Fill select and select a value with afterStateUpdated

I have tried this, but with a select it does not work correctly:
https://filamentphp.com/docs/3.x/forms/advanced#generating-a-slug-from-a-title

I attach code:
Forms\Components\Select::make('customer_id')
   ->relationship('customer', 'name')
   ->afterStateUpdated(fn (string $operation, Forms\Set $set) => $operation === 'create' ? $set('requested_by', auth()->user()->id) : null)
   ->searchable()
   ->required()
   ->preload()
   ->live(),

Forms\Components\Select::make('requested_by')
   ->relationship('requestedBy', 'name', fn (Builder $query, Get $get) => $query->requestTicket($get('customer_id')))
   ->required(),
Forms\Components\Select::make('customer_id')
   ->relationship('customer', 'name')
   ->afterStateUpdated(fn (string $operation, Forms\Set $set) => $operation === 'create' ? $set('requested_by', auth()->user()->id) : null)
   ->searchable()
   ->required()
   ->preload()
   ->live(),

Forms\Components\Select::make('requested_by')
   ->relationship('requestedBy', 'name', fn (Builder $query, Get $get) => $query->requestTicket($get('customer_id')))
   ->required(),
Advanced forms - Form Builder - Filament
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

Using both afterStateUpdated AND afterStateUpdatedJs
FilamentFFilament / ❓┊help
8mo ago
multiple() select not work with afterStateUpdated
FilamentFFilament / ❓┊help
2y ago
Error when select data with afterstateupdated
FilamentFFilament / ❓┊help
2y ago