ux icon indicating copy to clipboard operation
ux copied to clipboard

[LiveComponent] `onUpdated` hook is not called on `formValues`

Open norkunas opened this issue 11 months ago • 5 comments

I am using ComponentWithFormTrait and need to save submitted values (draft mode until full form submit). So I though that overriding $formValues and adding a hook will work. But that's not the case 🤔

class Component {
    // ...

    #[LiveProp(writable: true, fieldName: 'getFormName()', onUpdated: 'formValuesUpdated')]
    public array $formValues = [];

    public function formValuesUpdated(): void
    {
        // never called
    }
}

Is there a better way to hook for this?

norkunas avatar Jan 27 '25 13:01 norkunas

PostHydrate ?

smnandre avatar Jan 27 '25 21:01 smnandre

Thanks. it's a minus that I can't inject Request and need to interact with RequestStack.. But why onUpdated hook does not work here?

norkunas avatar Jan 28 '25 04:01 norkunas

I believe props were not made for complex objects at first (as we should repeat these values are serialized and accessible entirely in the DOM

smnandre avatar Feb 07 '25 23:02 smnandre

Hey, thanks for your report! There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

carsonbot avatar Aug 08 '25 12:08 carsonbot

Still think this should be considered

norkunas avatar Aug 11 '25 04:08 norkunas