FilamentF
Filament3y ago
8 replies
elsonium

How to show error message in modal for custom Action::make()

Tables\Actions\Action::make('disburse-cash')
    ->label('Disburse Cash')
    ->icon('heroicon-o-cash')
    ->form([
        DateTimePicker::make('date')
            ->label('Commission Disbursement For Date')
            ->withoutTime()
            ->required(),
    ])
    ->action(function (Merchant $record, array $data): void {
        if ($data['date']) {

            $transactions = $record->transactions()->whereDate('payout_time', Carbon::parse($data['date'])->toDateString())->get();

            if (!$transactions->count()) {
                // filament form error throw
                throw new \Exception('No transactions found for the given date.');
                
                return;
            }
        }
    })

Throw seems just show laravel error, but how do i show it on the Action modal itself?
Was this page helpful?