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

16 messages · Page 1 of 1 (latest)

feral condor
#

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!');
})

No error no logging

grave anchorBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

hidden crown
#
Select::make('contact.status'). // 
->live()
->options(StatusEnum::class)
->afterStateUpdated(
    function ($state) {
      logger('Here save new status!');
})

$state is the value of the form field

feral condor
hidden crown
#

instead of logger use dd($state)

#

that select is in a form?

feral condor
#

Funny, I just tried that, no dd().

hidden crown
#

no javascript errors on browser console?

feral condor
#

THis is in a class EditWindow extends Component implements HasForms, HasActions

#

so oes that make difference?

hidden crown
#

if the form is configured correctly I dont think theres a problem.

feral condor
#

Javascrip error 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()

hidden crown
#

Nice

grave anchorBOT