Magento 2, issue with forgotpassword.phtml template override
-
25-12-2020 - |
Question
In my custom module I have created app/code/myVendor/myModule/view/frontend/layout/customer_account_forgotpassword.xml
. With below content I can see title is changing but form gets disappear instead of displaying the content in forgotpassword.phtml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<title>From my module</title>
</head>
<body>
<referenceContainer name="content">
<block class="Magento\Customer\Block\Account\Forgotpassword" name="forgotPassword" template="myVendor_myModule::form/forgotpassword.phtml">
<container name="form.additional.info" as="form_additional_info"/>
</block>
</referenceContainer>
</body>
</page>
I have done upgrading, compiling, deploying and emptied the cache.
Solution
try below code under <body>
tag of your xml file
<referenceContainer name="content">
<referenceBlock name="forgotPassword">
<action method="setTemplate">
<argument name="template" xsi:type="string">myVendor_myModule::form/forgotpassword.phtml</argument>
</action>
</referenceBlock>
</referenceContainer>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange