© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•15mo ago•
1 reply
Christophe

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?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

FileUpload in Livewire Component
FilamentFFilament / ❓┊help
2y ago
Livewire component in form
FilamentFFilament / ❓┊help
2y ago
ExportAction in Livewire component
FilamentFFilament / ❓┊help
2y ago
livewire component
FilamentFFilament / ❓┊help
4mo ago