Update two fields after select value changes

I have a Select field which updates the value of a TextArea. The TextArea also updates a second TextArea with it's own value. How can I trigger this event of the first TextArea, when I select a value in my Select?
3 Replies
toeknee
toeknee8mo ago
Select::make('my_field')
->live()
->afterStateUpdated(function($state, $set) {
$model = Model::find($state);
$set('text_value_1', $model->textvalue);
$set('text_value_2', $model->textValue2);
})
Select::make('my_field')
->live()
->afterStateUpdated(function($state, $set) {
$model = Model::find($state);
$set('text_value_1', $model->textvalue);
$set('text_value_2', $model->textValue2);
})
Daniel Plomp
Daniel Plomp8mo ago
Yeah, that is also what I intended. But I also want to update the text_value_2 from the text_value_1 field. So I'll try to use your example, but I just wondered if there was a way to trigger events?
toeknee
toeknee8mo ago
If you set text_value_1, the you can use text_value_1 to get text_value_2? and vice versa
Want results from more Discord servers?
Add your server