How to override / add custom html in Sonata Admin Login Form

62 Views Asked by At

Hello Symfony developers, I'm trying to override / add the custom html to the default Sonata Admin login form:

enter image description here

I tried to find the answer, but I think I can't found it because the threads I found are very old and they are not for my version of Symfony & Sonata Admin Bundle

My versions: Sonata Admin Bundle 4.27.0 Symfony 6.3.4

The template that I want to override is here: /home/offices/copyrent.crm.app/vendor/sonata-project/user-bundle/src/Resources/views/Admin/Security/login.html.twig

When I place it in: /home/offices/copyrent.crm.app/templates/bundles/SonataUserBundle/src/Resources/views/Admin/Security/login.html.twig

It doesn't work :(

1

There are 1 best solutions below

0
On BEST ANSWER

Original template file path:

<project-dir>/vendor/sonata-project/user-bundle/src/Resources/views/Admin/Security/login.html.twig

Is now placed in:

<project-dir>/templates/bundles/SonataUserBundle/Admin/Security/login.html.twig

In the login.html.twig template:

{% extends "@!SonataUser/Admin/Security/login.html.twig" %}
{% block sonata_wrapper %}
    ...
{% endblock %}

Applicable to:
Sonata Admin Bundle 4.27.x
Symfony 6.3.x