Magento 2 - How to extend customer account creation template
-
14-04-2021 - |
Pergunta
I want to extend the customer account creation template (register.phtml) of the Luma theme. I copied the register.phtml to my custom theme directory:
\app\design\frontend\my\theme\module-customer\view\frontend\templates\
and modified it. After flushing the cache and refreshing the browser I can't see my changes.
What is wrong?
Is it always necessary to copy the template in a custom theme folder or is it also possible to copy it to the view folder of my custom module?
Thanks.
Marco
Solução
Solution: I tried the hints, but they didn't solve the problem. After searching for a while I figured out the following path which is working:
app/design/frontend/my/theme/Magento_Customer/templates/form
Outras dicas
your current path of template file is worng
\app\design\frontend\my\theme\module-customer\view\frontend\templates\
the correct path will be
\app\design\frontend\my\theme\module-customer\templates\
Copy the layout file to your theme.
Copy the customer account creation layout XML file from below location
/vendor/magento/module-customer/view/frontend/layout/customer_account_create.xml
to your theme that you’re editing
/app/design/frontend/<Vendor>/<Theme>/Magento_Customer/layout/customer_account_create.xml
If the template folder does not exists then create a template folder in the given path
/app/design/frontend/<Vendor>/<Theme>/Magento_Customer/templates/form/register.phtml
replace the below line of code of layout file (which one is copy from core magneto)
<block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="form/register.phtml">
to
<block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="Magento_Customer::/form/register.phtml">
Copy the html code from below location and paste into register.phtml (which one is created in theme directory)
vendor/magento/module-customer/view/frontend/templates/form