Update text input dynamic based off other important

I have this form schema
Toggle::make('includeTable')
->label('Include table')
->default(true)
->reactive()
->live(),
Toggle::make('includeChart')
->label('Include chart')
->default(false)
->reactive()
->live(),
Select::make('animation')
->label('Animation')
->options([
'none' => 'None',
'confetti' => 'Confetti',
'Fireworks' => 'Fireworks',
])
->default('none')
->reactive()
->live()
->columnSpanFull(),
TextInput::make('url')
->label('URL')
->readOnly()
Toggle::make('includeTable')
->label('Include table')
->default(true)
->reactive()
->live(),
Toggle::make('includeChart')
->label('Include chart')
->default(false)
->reactive()
->live(),
Select::make('animation')
->label('Animation')
->options([
'none' => 'None',
'confetti' => 'Confetti',
'Fireworks' => 'Fireworks',
])
->default('none')
->reactive()
->live()
->columnSpanFull(),
TextInput::make('url')
->label('URL')
->readOnly()
I would like to update the url text input, based off the other input like crafting a url, localhost:8000/embed?animation=fireworks
5 Replies
Jpac14
Jpac14OP4w ago
But I don't want to use afterStateUpdate on each input is there a better way That I can just have a function on the url to get the state when it's updated Could I even link it in with extra attributes and use alpinejs to update it? Or is afterStateUpdate my best bet?
toeknee
toeknee4w ago
is this a custom form in a custom request? Or is this part of the panel builder? But you can either use default() if it's a new form or if it's a form that is prefilled with fill() just get the var from the request and set it in the fill data
Jpac14
Jpac14OP4w ago
It is apart of the panel builder inside a header action, with a modal form? I have tried that, but I want the text input to update when I change the toggles or the select?
toeknee
toeknee4w ago
So just use $set(‘field’, ‘value’) in an afterStateUpdated method.
Jpac14
Jpac14OP4w ago
For each one, okay. Thanks. I though there would be an easier way.

Did you find this page helpful?