I find crudID in twig this method:
{{ ea.crudControllers.findCrudIdByCrudFqcn(ea.crud.controllerFqcn) }}
Is there an easier method?
thanks
app.request.query.get('crudId')
not very elegant as well, but you can create your custom twig function
public function getCrudId(): string{
return $this->requestStack->getMasterRequest()->query->get('crudId');
}
and requestStack can be added in twig construct method
private $requestStack;
public function __construct(RequestStack $requestStack){
$this->requestStack = $requestStack;
}
then in twig
{{ getCrudId() }}
gets you current crud id
thanks jakub, actually, I did open the issue on purpose because someone may search this methods
ha!
you got me thinking, I have few custom actions in my crud controllers and I always had an annoying issue, how to get back to an index page easily, so I created another twig function
public function getBackUrl( $crudClass ): string {
return $this->crudUrlGenerator
->build()
->setController($crudClass)
->setAction(Action::INDEX);
}
then in twig
{{ getBackUrl(ea.crud.controllerFqcn) }}