Refresh Form With Dynamic Element Names

I have a form that I call from a relation manager. The form has two pieces - the first piece shows the current items in the order and allows customers to modify those selections. The second piece allows customers to make a new selection. When the customer submits the new item, I want the form to refresh and show the updated selections. I can trigger the refresh using:
// action
->after(function ($livewire) {
$livewire->dispatch('refreshModal');
}),

// relation manager
#[On('refreshModal')]
public function refresh(): void
{
// unset the form
unset($this->cachedForms['mountedTableActionForm']);
// reload the form
$this->cacheForm('mountedTableActionForm', null);
}
// action
->after(function ($livewire) {
$livewire->dispatch('refreshModal');
}),

// relation manager
#[On('refreshModal')]
public function refresh(): void
{
// unset the form
unset($this->cachedForms['mountedTableActionForm']);
// reload the form
$this->cacheForm('mountedTableActionForm', null);
}
This process works for modifying a selection. However, when I try to use it for adding a new selection I get the error Livewire Entangle Error: Livewire property cannot be found. So there is a form section for the newly selected item but none of the values are filled in correctly. I define the form component using
Select::make('existingSelectionInfo.' . $existingSelection->id . '.mealId')
Select::make('existingSelectionInfo.' . $existingSelection->id . '.mealId')
So it is named dynamically. This might be more of a Livewire question than an issue with Filament. But basically my question is - how can I manipulate a value (wire:model) that is not present when the form is initially loaded. Thank you!
1 Reply
bwurtz999
bwurtz9995mo ago
Commenting again to see if anyone has any ideas. Thanks!