© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
Daniel Plomp

Close modal manually

I have an action that runs some custom code and then saves the record. I want to validate the form first, before executing the code. If the validation fails, I want the modal to close. Right now, it doesn't. Can I trigger this manually?

protected function getHeaderActions(): array
{
    return [
        \Filament\Actions\Action::make('finish')
            ->icon('heroicon-o-check-circle')
            ->label(__('strings.strings.actions.mark_as_resolved'))
            ->requiresConfirmation()
            ->color('success')
            ->action(function ($record, $livewire) {

                $livewire->validate(); // This validates the form correctly
                //$livewire->dispatchBrowserEvent('close-modal'); ??

                $record->status = 'published';
                $record->publish_at = now();
                $record->staging_vacancy->update(['status' => StagingVacancy::STATUS_REVIEW_FINALIZED]);
                $record->save();

                $this->redirect(StagingVacancyResource::getUrl());

            }),

    ];
}
protected function getHeaderActions(): array
{
    return [
        \Filament\Actions\Action::make('finish')
            ->icon('heroicon-o-check-circle')
            ->label(__('strings.strings.actions.mark_as_resolved'))
            ->requiresConfirmation()
            ->color('success')
            ->action(function ($record, $livewire) {

                $livewire->validate(); // This validates the form correctly
                //$livewire->dispatchBrowserEvent('close-modal'); ??

                $record->status = 'published';
                $record->publish_at = now();
                $record->staging_vacancy->update(['status' => StagingVacancy::STATUS_REVIEW_FINALIZED]);
                $record->save();

                $this->redirect(StagingVacancyResource::getUrl());

            }),

    ];
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Close Modal "hook"
FilamentFFilament / ❓┊help
3y ago
Custom close modal button
FilamentFFilament / ❓┊help
2y ago
Modal: Disable esc to close a Modal
FilamentFFilament / ❓┊help
2y ago
Manually triggering a modal action
FilamentFFilament / ❓┊help
5mo ago