0

I want to override the template Magento_Customer/templates/form/register.phtml in my own module.

At the moment the override is in my theme:

app/design/frontend/company/base/Magento_Customer/templates/form/register.phtml

but I need it in my module:

app/code/company/customer/???

Is this possible?


I am developing a module which is adding a new field in the customer register form.

I need the override in my module, otherwise users would have to add my module and also modify their theme.

1

1 Answer 1

1

For that you will have to override customer_account_create.xml in your own module.

So create "customer_account_create.xml" file in app\code\Your_module_vendor\Your_module_name\view\frontend\layout\customer_account_create.xml

And add below code into it.

    <?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">
        <body>
            <referenceBlock name="customer_form_register">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">VENDOR_MODULE::form/register.phtml</argument>
                </action>
            </referenceBlock>
        </body>
</page>

Now create your register.phtml in app\code\Your_module_vendor\Your_module_name\view\frontend\templates\form\register.phtml

Please upvote if it works. Thanks!

0

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.