F
Filament17mo ago
Ehsan

Update TextInput programmatically in reactive way

Hello guys, I have a reactive Select component on form and I want to update value of a TextInput based on the onchange value of this Select element. I tried to use value() method, but it sets the value only once on load and doesn’t change on Select changes. Please help.
Solution:
```php Select::make('select') ->options([ '1' => 'Option 1', '2' => 'Option 2',...
Jump to solution
2 Replies
Solution
LeandroFerreira
LeandroFerreira17mo ago
Select::make('select')
->options([
'1' => 'Option 1',
'2' => 'Option 2',
])
->reactive()
->afterStateUpdated(fn ($state, $set) => $set('text', $state)),
TextInput::make('text')
Select::make('select')
->options([
'1' => 'Option 1',
'2' => 'Option 2',
])
->reactive()
->afterStateUpdated(fn ($state, $set) => $set('text', $state)),
TextInput::make('text')
Ehsan
EhsanOP17mo ago
Thank you. Worked like charm
Want results from more Discord servers?
Add your server