PDF in Symfony 4

1. Create a default twig file for PDF {# ./templates/default/mypdf.html.twig #} <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title of the PDF</title> </head> <body> <h4>{{ title }}</h4> <p>Lorem Ipsum</p> </body> </html>…

Find in Symfony 4

$repository = $this->getDoctrine()->getRepository(Product::class); // look for a single Product by its primary key (usually "id") $product = $repository->find($id); // look for a single Product by name $product = $repository->findOneBy(['name' =>…

Radio button in Symfony 4

use Symfony\Component\Form\CallbackTransformer; $builder->add('roles', ChoiceType::class, array( 'choices' => array( 'user' => 'ROLE_USER', 'admin' => 'ROLE_ADMIN' ), 'label' => 'Role :' )); //roles field data transformer $builder->get('roles') ->addModelTransformer(new CallbackTransformer( function ($rolesArray) {…