FilamentF
Filament3y ago
G3z

Is it possible to add conditional confirmation on the save action ?

I tried the following in my EditPage subclass to ask for confirmation on a set condition but the callback inside requiresConfirmation is never called

protected function getSaveFormAction(): Action
{
    return Action::make('save')
        ->label(__('filament::resources/pages/edit-record.form.actions.save.label'))
        ->submit('save')
        ->keyBindings(['mod+s'])
        ->requiresConfirmation(function ($data) {
            if (false == empty($data['agreed_price'])) {
                if ($data['agreed_price'] != $data['sell_total_eur_gross']) {
                    return true;
                }
            }

            return false;
        });
}
Was this page helpful?