© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
7 replies
ejoi8

Hide "anonymous" actions in create page

Hello everyone... I added anonymous actions to show modal contains checkbox to generate PDF respective to the selected checkbox.

public static function form(Form $form): Form
{
    return $form
        ->schema([
            TextInput::make('name')->required()->label('Nama'),
            TextInput::make('email')->email()->maxLength(255),
            // anonymous actions - show modal popup contains checkbox to generate PDF respective to the category
            Actions::make([
                Action::make('Print  PDF')
                    ->form([
                        CheckboxList::make('category')
                            ->options([
                                'profail' => 'profail',
                                'sale' => 'sale',
                            ])
                    ])
                    ->action(function (array $data, $state, $record) {
                        // get the checkbox value, user_id to be process in controller
                        $data = array_merge($data,[ 'user_id' => $state['id']]);
                        return redirect()->route('pdf',['data' => $data]);
                    })
                    ->hiddenOn('create')
                ) 

            ]), 
        ]);
}
public static function form(Form $form): Form
{
    return $form
        ->schema([
            TextInput::make('name')->required()->label('Nama'),
            TextInput::make('email')->email()->maxLength(255),
            // anonymous actions - show modal popup contains checkbox to generate PDF respective to the category
            Actions::make([
                Action::make('Print  PDF')
                    ->form([
                        CheckboxList::make('category')
                            ->options([
                                'profail' => 'profail',
                                'sale' => 'sale',
                            ])
                    ])
                    ->action(function (array $data, $state, $record) {
                        // get the checkbox value, user_id to be process in controller
                        $data = array_merge($data,[ 'user_id' => $state['id']]);
                        return redirect()->route('pdf',['data' => $data]);
                    })
                    ->hiddenOn('create')
                ) 

            ]), 
        ]);
}

Currently the Action button "Print PDF" are available both in create & edit page. My question is
1. How can I hide the action button in create page and only show in edit page?.
-
->hiddenOn()
->hiddenOn()
it will cause
Method Filament\Forms\Components\Actions\Action::hiddenOn does not exist.
Method Filament\Forms\Components\Actions\Action::hiddenOn does not exist.

-
->hidden(function ( $state) { if (!$state) { return false; } })
->hidden(function ( $state) { if (!$state) { return false; } })
it will show
Typed property Filament\Forms\Components\Actions\Action::$component must not be accessed before initialization
Typed property Filament\Forms\Components\Actions\Action::$component must not be accessed before initialization

2. How can I open new tab when the "Print PDF" Action Button is clicked?
Solution
1 -
Actions::make([...])->hiddenOn('create')
Actions::make([...])->hiddenOn('create')
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

Testting anonymous actions
FilamentFFilament / ❓┊help
2y ago
Hide header actions on edit page
FilamentFFilament / ❓┊help
3y ago
how to test anonymous actions?
FilamentFFilament / ❓┊help
3y ago
Create Actions
FilamentFFilament / ❓┊help
3y ago