© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
biber

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)
$set('products', $products)
does not work sadly (with adding the Closure to the function).

Your help is appreciated!
Solution
Solved it via
$this->form->getFlatFields()['products']->state($products);
$this->form->getFlatFields()['products']->state($products);


It works, but maybe not the best way to do. :)
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

How to mutate repeater data?
FilamentFFilament / ❓┊help
3y ago
Set Repeater Data from Action Form
FilamentFFilament / ❓┊help
2y ago
Missing understanding about mutate data in repeater
FilamentFFilament / ❓┊help
16mo ago
Build repeater schema from action
FilamentFFilament / ❓┊help
12mo ago