@@ -548,5 +548,84 @@ property of the ``BlogPost`` entity before persisting it:
548548 }
549549 }
550550
551+ Page Templates for Custom Backends
552+ ----------------------------------
553+
554+ EasyAdmin provides several page templates which are useful when you are
555+ customizing your backends.
556+
557+ Login Form Template
558+ ~~~~~~~~~~~~~~~~~~~
559+
560+ Twig Template Path: ``@EasyAdmin/page/login.html.twig ``
561+
562+ It displays a simple username + password login form that matches the style of
563+ the rest of the backend. The template defines lots of config options, but most
564+ apps can rely on its default values:
565+
566+ .. code-block :: php
567+
568+ namespace App\Controller;
569+
570+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
571+ use Symfony\Component\HttpFoundation\Response;
572+ use Symfony\Component\Routing\Annotation\Route;
573+ use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
574+
575+ class SecurityController extends AbstractController
576+ {
577+ /**
578+ * @Route("/login", name="login")
579+ */
580+ public function login(AuthenticationUtils $authenticationUtils): Response
581+ {
582+ $error = $authenticationUtils->getLastAuthenticationError();
583+ $lastUsername = $authenticationUtils->getLastUsername();
584+
585+ return $this->render('@EasyAdmin/page/login.html.twig', [
586+ // parameters usually defined in Symfony login forms
587+ 'error' => $error,
588+ 'last_username' => $lastUsername,
589+
590+ // OPTIONAL parameters to customize the login form:
591+
592+ // the string used to generate the CSRF token. If you don't define
593+ // this parameter, the login form won't include a CSRF token
594+ 'csrf_token_intention' => 'authenticate',
595+ // the URL users are redirected to after the login (default: path('easyadmin'))
596+ 'target_path' => $this->generateUrl('admin_dashboard'),
597+ // the label displayed for the username form field (the |trans filter is applied to it)
598+ 'username_label' => 'Your username',
599+ // the label displayed for the password form field (the |trans filter is applied to it)
600+ 'password_label' => 'Your password',
601+ // the label displayed for the Sign In form button (the |trans filter is applied to it)
602+ 'sign_in_label' => 'Log in',
603+ // the 'name' HTML attribute of the <input > used for the username field (default: '_username')
604+ 'username_parameter' => 'my_custom_username_field',
605+ // the 'name' HTML attribute of the <input > used for the password field (default: '_password')
606+ 'password_parameter' => 'my_custom_password_field',
607+ ]);
608+ }
609+ }
610+
611+ Content Page Template
612+ ~~~~~~~~~~~~~~~~~~~~~
613+
614+ Twig Template Path: ``@EasyAdmin/page/content.html.twig ``
615+
616+ It displays a simple page similar to the list/show/edit/new pages, with the
617+ main header, the sidebar menu and the central content section. The only
618+ difference is that the content section is completely empty, so it's useful to
619+ display your own text contents, custom forms, etc.
620+
621+ Blank Page Template
622+ ~~~~~~~~~~~~~~~~~~~
623+
624+ Twig Template Path: ``@EasyAdmin/page/blank.html.twig ``
625+
626+ It displays a page with the same header and sidebar menu as the
627+ list/show/edit/new pages, but without the central content section. It's useful
628+ to define completely custom page, such as a complex dashboard.
629+
551630.. _`the base Symfony controller` : https://symfony.com/doc/current/book/controller.html#the-base-controller-class
552631.. _`GenericEvent class` : https://symfony.com/doc/current/components/event_dispatcher/generic_event.html
0 commit comments