EditAction in Livewire component

I have this Tree Structure where I want to edit each individual element. I'm using the Filament modal to handle this and rendering it like this:
<div>
{{ ($this->edit)(['post' => $item['id']]) }}

<x-filament-actions::modals />
</div>
<div>
{{ ($this->edit)(['post' => $item['id']]) }}

<x-filament-actions::modals />
</div>
So this sits inside a loop. The wrapper Livewire component handles the edit like this:
public function edit(): Action
{
return Action::make('edit')
->icon('heroicon-m-pencil-square')
->iconButton()
->color('gray')
->form([
TextInput::make('title')
->maxLength(255),
MainSubjectSelect::make('parent_id')
->label('Parent element')
->columnSpanFull()
->statePath('parent_id'),
])
->action(function (array $arguments) {
$post = SubjectTree::find($arguments['post']);

$post->update([
'title' => request()->input('title'),
'parent_id' => request()->input('parent_id'),
]);

$this->emit('refreshItems'); // Emit an event to refresh the items list
});
}
public function edit(): Action
{
return Action::make('edit')
->icon('heroicon-m-pencil-square')
->iconButton()
->color('gray')
->form([
TextInput::make('title')
->maxLength(255),
MainSubjectSelect::make('parent_id')
->label('Parent element')
->columnSpanFull()
->statePath('parent_id'),
])
->action(function (array $arguments) {
$post = SubjectTree::find($arguments['post']);

$post->update([
'title' => request()->input('title'),
'parent_id' => request()->input('parent_id'),
]);

$this->emit('refreshItems'); // Emit an event to refresh the items list
});
}
The problem is that the form is not filled in. It does retrieve the correct $post, when i dd($post) after the action it shows me the correct $post. How do I handle this?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server