biber
biber
FFilament
Created by biber on 1/24/2024 in #❓┊help
Mutate Repeater Data from Action
Hello, I want to mutate my Repeater data by inserting data from an import action on the model's resource edit page. In my models resource I have declared a form with a Repeater
Repeater::make('products')
->relationship()
->schema([
// ...
]);
Repeater::make('products')
->relationship()
->schema([
// ...
]);
The edit page has the following action:
protected function getActions(): array
{
return [
Action::make('import')
->label('Import Products')
->action(function (ComponentContainer $form) {
$formData = $form->getState();

$productImport = (new ProductImport);
$products = $productImport->import($formData['file'])->getProducts();

// $set('products', $products) ???
})
->form([
Forms\Components\FileUpload::make('file'),
]);
];
}
protected function getActions(): array
{
return [
Action::make('import')
->label('Import Products')
->action(function (ComponentContainer $form) {
$formData = $form->getState();

$productImport = (new ProductImport);
$products = $productImport->import($formData['file'])->getProducts();

// $set('products', $products) ???
})
->form([
Forms\Components\FileUpload::make('file'),
]);
];
}
How can I now fill the repeater with the gathered products? The callable $set('products', $products) does not work sadly (with adding the Closure to the function). Your help is appreciated!
3 replies