how to update state in custom field?
How do I update an entangled state variable so that the filament form knows the value has been updated?
I have a class that gets passed the state via $wire.$entangle({{ $getStatePath() }}')
In this case, I'm setting the state from an array of lat/lon coordinates [ 'lat' => 12, 'lon' => 45 ] in an array.
If in my javascript I then set state.lat = 56, how can I make sure laravel/filament knows it has changed so the ->afterStateUpdated() triggers?
3 Replies
You need to make the entanglement live. Livewire v3 is not reactive by default anymore.
state: $wire.{{ $applyStateBindingModifiers("entangle('{$statePath}')")
That would process the ->live() etc methods used on the Field::make()where? in what context?
I tried adding it to my livewire component's blade template:
<div x-data="{ state: $wire.{{ $applyStateBindingModifiers("$entangle('{$getStatePath()}')") }} }">
And I get:
Internal Server Error
ErrorException
Undefined variable $applyStateBindingModifiers
What does your component extend?
Iirc it needs to extend a Field
Can you share the class code?