Action on change of input
I'd like to execute a custom action (like some code) when I toggle one of those two values; is this possible?
17 Replies
->reactive()->afterStateUpdated()
Ohh, and how can I access the current model then?
Current model or data?
So like here:
Was that a question?
Well, the second parameter is that also the record then here?
It's the record, but not the current data. You can use
$get()
for thatLike this then?
Because I need the whole resource model
and the $get() is undefined
Do you need the model or the updated data?
I need the data from the switch or the selectbox (depending on what the user changes)
But I need the model (with old data is OK) too
So
->formatStateUsing(function ($state, $record)
should work on an EditPage
For a EditPage you likely need ->formatStateUsing(function ($state, $livewire) { $livewire->getState()
Ah, it's in the resource itself (Class that extends Resource)
What do you mean?
Still no idea what you mean.
Also there is no
$resource
I thinkSo, after that I toggle a switch in the interface on the edit page, I want to execute an action.
This action needs the value of the switch (on/off, e.g. true and false)
but also the current resource
Livewire ->getstate() throws an exception; Method App\Filament\Resources\DeviceResource\Pages\EditDevice::getState does not exist.
Complete toggle component;
Solution was:
Can be closed, thanks for the help!