Can I get the value of a select and run a method? Not ubmitting a form.

This doen't even log after a change in the select
Select::make('contact.status'). //
->live()
->options(StatusEnum::class)
->afterStateUpdated(
function () {
logger('Here save new status!');
})
Select::make('contact.status'). //
->live()
->options(StatusEnum::class)
->afterStateUpdated(
function () {
logger('Here save new status!');
})
No error no logging
10 Replies
Bruno Pereira
Bruno Pereira2d ago
Select::make('contact.status'). //
->live()
->options(StatusEnum::class)
->afterStateUpdated(
function ($state) {
logger('Here save new status!');
})
Select::make('contact.status'). //
->live()
->options(StatusEnum::class)
->afterStateUpdated(
function ($state) {
logger('Here save new status!');
})
$state is the value of the form field
ddoddsr
ddoddsrOP2d ago
You would expect the logger in laravel.log and I don't get anything. As if the state is not Updating
Bruno Pereira
Bruno Pereira2d ago
instead of logger use dd($state) that select is in a form?
ddoddsr
ddoddsrOP2d ago
Funny, I just tried that, no dd().
Bruno Pereira
Bruno Pereira2d ago
no javascript errors on browser console?
ddoddsr
ddoddsrOP2d ago
THis is in a class EditWindow extends Component implements HasForms, HasActions so oes that make difference?
Bruno Pereira
Bruno Pereira2d ago
if the form is configured correctly I dont think theres a problem.
ddoddsr
ddoddsrOP2d ago
Javascrip error
Uncaught TypeError: Cannot read properties of null (reading 'status')
Uncaught TypeError: Cannot read properties of null (reading 'status')
So it is broken before selection. I have to populate the status first. I made a local public $status for the status and now I see it in dd()
Bruno Pereira
Bruno Pereira16h ago
Nice

Did you find this page helpful?