Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormActionType - Confirmation does not work with Closure #139

Closed
jc-beyer-tqgg opened this issue Oct 23, 2024 · 2 comments
Closed

FormActionType - Confirmation does not work with Closure #139

jc-beyer-tqgg opened this issue Oct 23, 2024 · 2 comments

Comments

@jc-beyer-tqgg
Copy link

jc-beyer-tqgg commented Oct 23, 2024

Hey everyone !

The docs say that confirmation can be set to bool, array or callable.
But when i pass a Closure, i get an error rendering the datatable. It works for href etc. in the ButtonType.

->addRowAction('delete', FormActionType::class, [
                'label' => 'Delete',
                'button_attr' => [
                    'class' => 'btn btn-danger btn-sm',
                ],
                'confirmation' => function(Entity $entity): array {
                    return [
                        'title' => 'Delete',
                        'message' => sprintf(
                            'Are you sure you want to delete Channel: [%s]?',
                            $entity->getChannel()->getName()
                        ),
                    ];
                },

Is this a bug, wrong doc or am I doing something wrong ?

Thanks in advance !

@Kreyu
Copy link
Owner

Kreyu commented Oct 23, 2024

Hey @jc-beyer-tqgg, thanks for the report. There was a bug and I just pushed a fix to version 0.24.3.

Please note that options allowed in the confirmation array (including array returned from callable) are:

  • translation_domain
  • label_title (you'll probably want to use this option instead of title)
  • label_description (you'll probably want to use this option instead of message)
  • label_confirm
  • label_cancel
  • type

@jc-beyer-tqgg
Copy link
Author

@Kreyu Thanks for the super fast fix ! Really appriciate your work here

@Kreyu Kreyu closed this as completed Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants