我正在学习Symfony和EasyAdmin,我的下一个任务是添加一个按钮,该按钮将从表中打印(generate )选定的行。我已经签了EasyAdmin文档,如果有教程或更多的信息,但没有运气。https://symfony.com/bundles/EasyAdminBundle/current/crud.html
我该怎么接近它?有什么方法是我应该使用的还是捆绑的?
我找到了这个帖子:PDF document creation EasyAdmin symfony 5,但没有人回答。关于这件事没有多少信息。
Symfony 5.4,EasyAdmin 4
发布于 2022-01-26 16:00:48
我认为你应该为此制定一个海关行动。
假设您已经设置了一个ProductCrudController类。在该类中,您必须重写以下内容:
public function configureActions(Actions $actions): Actions
{
$viewProductInPDFFormat = Action::new('viewPDF', 'View in PDF', 'fa fa-file-pdf-o')
->linkToRoute('name_of_route_that_generate_pdf_on_one_product',
function (Product $product): array {
return [
'id' => $product->getId(),
];
});
return $actions
//will add the action in the page index view
->add(Crud::PAGE_INDEX, $viewProductInPDFFormat)
//will add the action in the page detail view
->add(Crud::PAGE_DETAIL, $viewProductInPDFFormat)
;
}https://stackoverflow.com/questions/70865327
复制相似问题