F
Filament15mo ago
ElCoco

Save to DB after deleting a repeater element

I am implementing a ChatGPT-like UI. I use a Repeater to populate the list of conversations. When I press the delete icon it deletes properly the element from the array but I would have to press Submit to save the modified list into the DB. What I want is to save the array immediately after pressing the Delete button (actually this control ideally doesn't even have a submit button). I played a bit with deleteAction object (https://filamentphp.com/docs/3.x/forms/fields/repeater#customizing-the-repeater-action-objects) but it seems it can just setup the action in specific ways instead of running code after pressing the delete button. This is my form:
protected function getFormSchema(): array
{
// dd($this->conversation);
return [
FilamentForms\Repeater::make('history')
->schema([
FilamentForms\TextInput::make('name')
->readOnly(true)
->label('')
])
->addable(false)
->model($this->conversation)
->statePath('data')
];
}
protected function getFormSchema(): array
{
// dd($this->conversation);
return [
FilamentForms\Repeater::make('history')
->schema([
FilamentForms\TextInput::make('name')
->readOnly(true)
->label('')
])
->addable(false)
->model($this->conversation)
->statePath('data')
];
}
4 Replies
Patrick Boivin
Patrick Boivin15mo ago
Have you tried ->after() on the repeater's delete action?
ElCoco
ElCocoOP15mo ago
Hi! No I didn't try that actually. At the end I changed my approach to just having a custom page inside the filament panel so I had more control. Another things I was missing is that I should be able to select one of the Repeater elements and then update the conversation on the right. I was taking way too much time to figure these things out that's why I changed to a custom page. Thx for your help!
phphelloworld
phphelloworld12mo ago
Hi! Could you explain please where and how to use it to save immediately to DB after deleting a repeater element?
Want results from more Discord servers?
Add your server