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() 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!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server