Short description of what this feature will allow to do:
Currently, batch actions in EasyAdmin are limited to simple triggers without the ability to attach a fully customizable Symfony Form. This feature would allow developers to define and use a custom FormType for batch actions, enabling additional user input, validation, and structured data handling before processing the selected entities. This would make batch actions significantly more flexible and suitable for more complex workflows.
Example of how to use this feature
// src/Controller/Admin/ProductCrudController.php
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use App\Form\BatchUpdateType;
public function configureActions(Actions $actions): Actions
{
return $actions->addBatchAction(
Action::new('batchUpdate', 'Update Products')
->useForm(BatchUpdateType::class) // proposed API
->linkToCrudAction('handleBatchUpdate')
);
}
public function handleBatchUpdate(BatchActionDto $dto, Request $request): Response
{
$form = $dto->getForm(); // proposed access to submitted form
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$entityIds = $dto->getEntityIds();
// apply updates using both selected entities and form data
}
return $this->render('admin/batch_update.html.twig', [
'form' => $form->createView(),
]);
}
// src/Form/BatchUpdateType.php
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
class BatchUpdateType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('status', ChoiceType::class, [
'choices' => [
'Draft' => 'draft',
'Published' => 'published',
],
]);
}
}
Short description of what this feature will allow to do:
Currently, batch actions in EasyAdmin are limited to simple triggers without the ability to attach a fully customizable Symfony Form. This feature would allow developers to define and use a custom FormType for batch actions, enabling additional user input, validation, and structured data handling before processing the selected entities. This would make batch actions significantly more flexible and suitable for more complex workflows.
Example of how to use this feature