afterStateUpdated() now working

Hey, I created a custom page where I want to update a fields value based on another fields value. I found in a docs an example which does exactly what I need
TextInput::make('title')
->live()
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state))),
TextInput::make('slug')
TextInput::make('title')
->live()
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state))),
TextInput::make('slug')
The problem is that if I use this example on one of my resources it works correctly, but using it on my custom page it does not do anything. I checked the network tab and there are no requests made to the server whenever I write something in the input for the title. Do I need to import a trait in my custom page class or something else in order for this to work as intended ?
1 Reply
bwurtz999
bwurtz9992y ago
Do you have a public variable title on your custom page? It's all Livewire behind the scenes and with pure Livewire you need that variable declared when the page initially loads

Did you find this page helpful?