Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

devhoussam123's avatar

Can't open a modal from filament notification action

when I get redirected to a page with a notification I have an action I want to open a modal when action is clicked I use the code below but I get this error:

Unable to call component method. Public method [mountAction] not found on component

Test.php

use Filament\Notifications\Actions\Action as NotificationAction;

    public function sendSuccessNotification(): void
    {
        Notification::make()
            ->success()
            ->title(__('Title'))
            ->body(__('Body'))
            ->actions([
                NotificationAction::make('restore')
                    ->button()
                    ->extraAttributes([
                        'wire:click' => str('mountAction(\'openModalAction\')'),
                    ]),
            ])
            ->persistent()
            ->send();
    }

Test2.php

public function openModalAction(): Action
    {
        return Action::make('openModal')
            ->modalIcon('bi-search')
            ->modalHeading(__('Heading'))
            ->modalDescription(__('Lorem Ipsum is simply dummy text of the printing and typesetting industry.'))
            ->form([
                TextInput::make('text'),
            ])
            ->action(function (): void {
            });
    }
0 likes
3 replies
alden8's avatar

@devhoussam123

-- incorrect wire:click syntax:

--- in the sendSuccessNotification method, make sure the wire:click directive correctly invokes the openModalAction method on the appropriate target component. Verify the casing and namespace, and consider using Blade helpers like @entangle or @wire() for a more reactive approach

--- for example, try replacing wire:click with wire:[email protected]="restore" and using a public property in Test to control the modal visibility:

// Test.php
public $showMyModal = false;

// NotificationAction
->wire:[email protected]="showMyModal"

// Test2.php (possibly in a Livewire component)
public function render()
{
    return $this->modal(Test2::class, ['visible' => $this->showMyModal]);
}

-- missing mountAction method:

--- check that the openModalAction method in Test2.php actually exists. If it's intended to handle mounting the modal content, provide an implementation like this:

public function openModalAction(): void
{
    // ... modal configuration including form ...
}

public function mountAction(): void
{
    // Fetch any necessary data or perform actions upon modal mount
}

-- namespace or component targeting issues:

--- depending on how your components are structured, you might need to specify the component path in the wire:click directive to ensure it reaches the correct component instance --- if Test and Test2 are part of different Livewire components, use the component class name and a dot before the method name, e.g., wire:click="$openModalAction()" within Test

Please or to participate in this conversation.