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
awcodes
awcodes6d ago
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()
treii28
treii28OP4d ago
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
Matthew
Matthew4d ago
What does your component extend? Iirc it needs to extend a Field Can you share the class code?
Want results from more Discord servers?
Add your server