Closed pietaj closed 5 months ago
Take any admin list with a couple of records, select one of them, then select "all records" checkbox by the batch actions and click any batch action with a confirmation page (batch delete will do). The confirmation page will show 'you are about to delete all elements. Proceed?'
I consider it should delete all elements then, so controller should be corrected.
Do you mind a PR @pietaj ?
Hello @VincentLanglet. Thanks for the feedback. I'll do the PR, no problem
Subject
When performing a batch action with a confirmation page, there is an inconsistency what the user will get in the confirm vs what sonata will really do.
Steps to reproduce
Take any admin list with a couple of records, select one of them, then select "all records" checkbox by the batch actions and click any batch action with a confirmation page (batch delete will do). The confirmation page will show 'you are about to delete all elements. Proceed?'
This is not surprising, as the template
admin-bundle/src/Resources/views/CRUD/batch_confirmation.html.twig
states:so check if the 'all elements' checkbox is checked, if yes - message_batch_all_confirmation
but in the controller
admin-bundle/src/Controller/CRUDController.php
we have
so the controller adds the identifiers even if all elements is selected, and this implies that a sequence of AND and OR statements is added to the query.
Expected results
I would expect, that sonata will delete all elements, as the confirmation page stated that it will do so
Actual results
Sonata will delete only the one selected element
The question is - should Sonata prioritize all elements and the controller should be corrected, or should idx be prioritized and the confirmation page should be addjusted
I'm happy to help with the fix, but a decision needs to be made