© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
6 replies
nowak

Is it possible to add validation to a `Action::make()` before opening the confirmation modal?

I have added a header action to my table, where I have tried to add validation in the
->before()
->before()
lifecycle hook:
Action::make('acceptAll')
  ->before(function ($action, $livewire) {
    Log::debug('Before hook');
    $groupOrders = $livewire->getTableRecords();
    foreach ($groupOrders as $groupOrder) {
      if (!$groupOrder->courier) {
        Notification::make()
          ->warning()
          ->title('Missing Courier')
          ->body('Group order with route ID ' . $groupOrder->route->id . ' does not have a courier assigned. Please assign a courier and try again.')
          ->persistent()
          ->send();
        $action->cancel();
        return;
      }
    }
  })
  ->requiresConfirmation()
  ->action(function ($action, $livewire) use ($orderStatusIds){
      // Action logic
  }),
Action::make('acceptAll')
  ->before(function ($action, $livewire) {
    Log::debug('Before hook');
    $groupOrders = $livewire->getTableRecords();
    foreach ($groupOrders as $groupOrder) {
      if (!$groupOrder->courier) {
        Notification::make()
          ->warning()
          ->title('Missing Courier')
          ->body('Group order with route ID ' . $groupOrder->route->id . ' does not have a courier assigned. Please assign a courier and try again.')
          ->persistent()
          ->send();
        $action->cancel();
        return;
      }
    }
  })
  ->requiresConfirmation()
  ->action(function ($action, $livewire) use ($orderStatusIds){
      // Action logic
  }),

But the before hook does not trigger before the confirmation modal is opened. Am I doing something wrong? Or is there simply no lifecycle hook that triggers before the action modal is opened?
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

Confirmation modal before action.
FilamentFFilament / ❓┊help
3y ago
Opening a confirmation modal after validation.
FilamentFFilament / ❓┊help
3y ago
Is it possible to add conditional confirmation on the save action ?
FilamentFFilament / ❓┊help
3y ago
Is it possible to add an icon to the modal submit action?
FilamentFFilament / ❓┊help
3y ago