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
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
EhsanOP2y ago
Thank you. Worked like charm

Did you find this page helpful?