© 2026 Hedgehog Software, LLC

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

iterate multiple actions in action group

I'm working on a project where has a submission that accepts multiple files with various file types, I'm trying add multiple buttons that represent files and when any of them is clicked this file is downloaded and these buttons should be grouped in an action group. Hence, I'm trying to add a function inside the action group that gets the files from the record then iterates on them so each file can have a button. But that doesn't seem to work due to
ActionGroup::
ActionGroup::
not accepting a closure or an array with a closure inside. So initially I managed to create a single action that when clicked it fetches the links then redirects to a blade file which contains a JS code that manages to open each file in a new tab
Action::make('view_forms')
                            ->label('View Forms')
                            ->icon('heroicon-o-document')
                            ->action(function (Submission $record) {
                                $mediaLinks = $record->getMedia('submission_forms')->map(function ($media) {
                                    return $media->getFullUrl();
                                });

                                session()->put('mediaLinks', $mediaLinks);

                                return redirect('forms/redirect');

                            }),
Action::make('view_forms')
                            ->label('View Forms')
                            ->icon('heroicon-o-document')
                            ->action(function (Submission $record) {
                                $mediaLinks = $record->getMedia('submission_forms')->map(function ($media) {
                                    return $media->getFullUrl();
                                });

                                session()->put('mediaLinks', $mediaLinks);

                                return redirect('forms/redirect');

                            }),


Route::get('forms/redirect', function () {
    $mediaLinks = session()->get('mediaLinks');
    return view('redirects.redirect-pdf', [
        'mediaLinks' => $mediaLinks
    ]);
})->middleware(['auth', 'verified']);
Route::get('forms/redirect', function () {
    $mediaLinks = session()->get('mediaLinks');
    return view('redirects.redirect-pdf', [
        'mediaLinks' => $mediaLinks
    ]);
})->middleware(['auth', 'verified']);


    <script>

        let mediaLinks = @json($mediaLinks);

        //used to open the media links in new tab
        mediaLinks.map((link) => {
            window.open(link, '_blank');
        });

        //redirect back to the previous page
        setTimeout(() => {
            window.location.href = '{{ redirect()->back()->getTargetUrl() }}';
        }, 3000);

    </script>
    <title>Redirecting</title>
</head>
<body>
...
    <script>

        let mediaLinks = @json($mediaLinks);

        //used to open the media links in new tab
        mediaLinks.map((link) => {
            window.open(link, '_blank');
        });

        //redirect back to the previous page
        setTimeout(() => {
            window.location.href = '{{ redirect()->back()->getTargetUrl() }}';
        }, 3000);

    </script>
    <title>Redirecting</title>
</head>
<body>
...
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

Actions in a table group header
FilamentFFilament / ❓┊help
10mo ago
How to group actions together in dropdown in Form Actions?
FilamentFFilament / ❓┊help
3y ago
Action Group Layout
FilamentFFilament / ❓┊help
14mo ago
action group icon
FilamentFFilament / ❓┊help
16mo ago