© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
Altffenser

afterStateUpdate() with delay on select component

Hello guys, I have created a form with a specific operation that so far my development experience has been perfect and only with this small detail.

My intention is to form the "Title" field from selector menus, the detail is that there is a delay when having selected an option; the "title" field remains with the previous value.

my
afterStateUpdate()
afterStateUpdate()
method:
->live(false)
->afterStateUpdated(function (Set $set) {
  $commission = Commission::find($this->session_commission_id);
  $set('title', 'Session ' . ($this->session_type == 1 
? "Special " 
: ($this->session_type == 2 
  ? "Ext. " 
  : "Ord. ")) . 
$this->session_consecutive . " " . ($commission?->type == 1
  ? "of the commission " . ($commission?->id != 19 ? 'of ' 
  : '') . $commission?->name 
    : ($commission?->type == 2
      ? "committee  " . $commission?->name 
      : "of " . $commission?->name)));
})
->live(false)
->afterStateUpdated(function (Set $set) {
  $commission = Commission::find($this->session_commission_id);
  $set('title', 'Session ' . ($this->session_type == 1 
? "Special " 
: ($this->session_type == 2 
  ? "Ext. " 
  : "Ord. ")) . 
$this->session_consecutive . " " . ($commission?->type == 1
  ? "of the commission " . ($commission?->id != 19 ? 'of ' 
  : '') . $commission?->name 
    : ($commission?->type == 2
      ? "committee  " . $commission?->name 
      : "of " . $commission?->name)));
})

My Select component:
Select::make('session_commission_id')
  ->options([
      '1' => 'Any type of commission',
      '2' => 'Other type of commission',
      '3' => 'Another type of commission',
  ])
  ->searchable()
  ->preload()
  ->native(false)
  ->label('Commission')
  ->required()
  ->rules('required')
  ->live(true)
  ->afterStateUpdated(function (Get $get) {
      $this->session_commission_id = $get('session_commission_id');
  }),
Select::make('session_commission_id')
  ->options([
      '1' => 'Any type of commission',
      '2' => 'Other type of commission',
      '3' => 'Another type of commission',
  ])
  ->searchable()
  ->preload()
  ->native(false)
  ->label('Commission')
  ->required()
  ->rules('required')
  ->live(true)
  ->afterStateUpdated(function (Get $get) {
      $this->session_commission_id = $get('session_commission_id');
  }),

Is there something I am doing wrong, or is the behavior I expect my component to take not possible?
Thanks!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

afterstateupdate
FilamentFFilament / ❓┊help
2y ago
Footer on Select component
FilamentFFilament / ❓┊help
2y ago
Readonly on 'Select Component'
FilamentFFilament / ❓┊help
2y ago
upload image from afterStateUpdate of another component
FilamentFFilament / ❓┊help
16mo ago