can we entangle state form field into livewire component.

custom-field-filament.blade.php
<livewire:custom-component wire:model="{{$getStatePath()}}"/>
<livewire:custom-component wire:model="{{$getStatePath()}}"/>
2 Replies
Kaesa Lyrih
Kaesa LyrihOP3mo ago
How can I properly sync state between a custom Filament form field and a nested Livewire component? I’m creating a custom Filament form field using:
php artisan make:form-field MyCustomField
php artisan make:form-field MyCustomField
In the field’s Blade view, I render a child Livewire component like this:
@livewire('my-livewire-component', ['value' => $getState()], key($getStatePath()))
@livewire('my-livewire-component', ['value' => $getState()], key($getStatePath()))
My goal is to synchronize the state between the Filament field and the nested Livewire component (child) — in both directions. What I’ve tried so far: * Passing $getState() as a prop to the Livewire component → ✅ works * Adding a listener (updateFieldState) in the Filament form component → ❌ likely incorrect implementation, nothing happens Questions: * What is the correct way to update the parent form state from a nested Livewire component? * Is there a way to bind the child component directly to the Filament field’s state (e.g., via entangle())? Or is Alpine.js required as a bridge? The Filament docs don’t cover this pattern, and I want to avoid hacky workarounds if there’s a cleaner or more idiomatic way to do it. Any insight or example would be greatly appreciated. Thanks! owh i will try. - parent
#[On('locationUpdated')]
public function updateLocation($location)
{
$this->formData['location'] = $location;
}
#[On('locationUpdated')]
public function updateLocation($location)
{
$this->formData['location'] = $location;
}
- child
public function updatedLocation()
{
// Dispatch to parent
$this->dispatch('locationUpdated', $this->location);
}
public function updatedLocation()
{
// Dispatch to parent
$this->dispatch('locationUpdated', $this->location);
}

Did you find this page helpful?