I try to override admin login template, using Layout Block Argument. Here is the files I created to do that:

in Vendor/Module/view/adminhtml/layout/admin_login.xml I tried:

<referenceBlock name="admin.login">
     <argument name="template" xsi:type="string">vendor_module::admin/login.phtml</argument>

But nothing Happened, so I changed with:

<referenceBlock name="admin.login">
   <action method="setTemplate">
     <argument name="template" xsi:type="string">vendor_module::admin/login.phtml</argument>

And now in magento2/var/log/system.log I have:

main.CRITICAL: Invalid template file: 'vendor_module::admin/login.phtml' in module: 'Magento_Backend' block's name: 'admin.login'

I have created the template file login.phtml in Vendor/Module/view/adminhtml/templates/admin/

so I don't know what's I'm doing wrong. I'm very new to Magento 2, I took the time to read Dev Docs and many forums but I can't find the solution by myself, anyone could help me?

Thank you so much!

2 Answers 2


In fact the problem come from that I'm not able to find a block to extend corresponding to login.phtml (view/adminhtml/templates/admin/login.phtml), if I enable printing block and template in Magento admin, I can see that the block name I should extend is \Magento\Backend\Block\Template, so I try to extend this one but it's a "top level" class. What I try: I created a block:

namespace Vendor\Module\Block\Adminhtml\Backend\Admin;

class Login extends \Magento\Backend\Block\Template

Add this line to my di.xml

<preference for="Magento\Backend\Block\Template" type="Vendor\Module\Block\Adminhtml\Backend\Admin\Login"/>

And create my Layout Vendor/Module/view/adminhtml/layout

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-login" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

     <referenceBlock name="admin.login">
          <block class="Rcdevs\Openotp\Block\Adminhtml\Backend\Admin\Login" name="admin_login" template="admin/login.phtml" />


and my view/adminhtml/templates/admin/login.phtml with the content I'd like to change.

The admin.login block has been well replaced with my template, but now the problem is because it's not a "particular block" all the phtml using \Magento\Backend\Block\Template are necessarily impacted and showing this message in system.log:

main.CRITICAL: Invalid template file: 'admin/login_buttons.phtml' in module: 'Vendor_Module' block's name: 'adminhtml_auth_login_buttons'

What can I do extend admin/login.phtml (admin.login block) only without touching others blocks? Thank you very much..


Did you use Vendor_Module or vendor_module?

Module path in layout config is defined as Vendor_Module, not vendor_module. Notice the uppercase in bold text.

For example, your module path is Project\Distributor, you call the module as Project_Distributor in layout config.

To change admin login block template, method 1:

<referenceBlock name="admin.login" template="Vendor_Module::admin/login.phtml" />

Or method 2:

<referenceBlock name="admin.login">
        <argument name="template" xsi:type="string">Vendor_Module::admin/login.phtml</argument>

The filename is adminhtml_auth_login.xml, not admin_login.xml. Source: Magento 2 DevDoc

Make sure that your block template file path is /path/to/app/code/Vendor/Module/view/adminhtml/templates/admin/login.phtml. Notice that view, adminhtml, and templates are in lowercase.

After modifying your xml, flush magento cache (cache:flush), then reload your web browser.

  • Hello, thank you for your answer - yes I did, I made a mistake when writing vendor_module. The problem is elsewhere...
    – JulienR
    Commented Jan 31, 2017 at 6:59
  • I have updated my answer, about the filename. Could you try it? Commented Jan 31, 2017 at 7:42
  • Thank you very much, I don't know what's I'm doing wrong, but method 1 gives: main.CRITICAL: Invalid template file: 'Rcdevs_Openotp::admin/login.phtml' in module: 'Magento_Backend' block's name: 'admin.login', and method 2 do nothing. I have the correct file path in lowercase... Are you sure this method works for this particular case?
    – JulienR
    Commented Jan 31, 2017 at 10:17
  • I FOUND MY MISTAKE!!! If you have a vendor and a module name like mine, VENdor and ModULE (in this case it's strange but it's my case...) you HAVE TO write VENdor_ModULE not Vendor_Module like explained in all doc and forums! Thank you so much.
    – JulienR
    Commented Jan 31, 2017 at 12:32
  • Yes, as I have warned you about the case sensitive... Commented Feb 2, 2017 at 2:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.