Christophe
Christophe
FFilament
Created by Christophe on 11/14/2024 in #❓┊help
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?
2 replies
FFilament
Created by Christophe on 11/7/2024 in #❓┊help
Custom form component
No description
4 replies
FFilament
Created by Christophe on 9/9/2024 in #❓┊help
Custom page messing up sidebar
No description
18 replies
FFilament
Created by Christophe on 5/17/2024 in #❓┊help
Possibility to hide a table on a list page
Hello there, I'm using a tree structure for a Resource but I just want to show the tree structure (as a widget) and don't need the table view. Can I hide the table or should I use a custom view to achieve this?
6 replies