Patrick | Der Echte!
afterStateUpdated $old does not work after using Builder/Block
This seems to be casued by multiple properties being updated by one Livewire request.
Livewire will iterate each property to be updated and trigger the *update * event for said property.
https://github.com/livewire/livewire/blob/main/src/Mechanisms/HandleComponents/HandleComponents.php#L290
Doing so, Livewire will call all updating Hooks on the Component.
https://github.com/livewire/livewire/blob/main/src/Features/SupportLifecycleHooks/SupportLifecycleHooks.php#L68
This will call Filament's
updatingInteractsWithForms
, which will write the current $data
to $oldFormState['data']
.
https://github.com/filamentphp/filament/blob/3.x/packages/forms/src/Concerns/InteractsWithForms.php#L63C20-L63C46
All of this is done before any updated
hook is executed, so it will result in $oldFormState['data']
equalling to the new data minus the last updated property. This does result in my $old
value being wrong.
I am not quite sure if this is the right way to keep track of old data, as Livewire does not seem to update the properties in order anyways.
In case of an updating event context, should the $oldFormState['data']
not only be set once and not for every update trigger?4 replies