I have a button "Registration for dealer" on customer/account/create/ page that outputs a popup. My goal is to render in the popup the default customer registration form that's fully functional. Popup modal is created with RequireJS and works as intended. Form's location is \vendor\magento\module-customer\view\frontend\templates\form\register.phtml

The layout is at vendor\magento\module-customer\view\frontend\layout\customer_account_create.xml

This is the content of my customer_account_create.xml

<?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">
            <referenceBlock name="form.additional.info">
                <block class="Alex\Lesson5Homework\Block\CustomBlock" name="custom.registration.block" as="custom_registration_block" template="Alex_Lesson5Homework::dealer_registration.phtml" />

This is PHP block that returns a simple string for now:

class CustomBlock extends Template
    public function getContent()
        return 'Dummy Content';

I use getContent in my phtml template

<div id="modal-content">
    <?php echo $this->getContent(); ?>
  • Create popup in Magento : integerbyteblog.in/magento/…
    – MP Raj
    Commented Sep 22, 2023 at 13:41
  • 1
    I have a popup already...
    – Dramorian
    Commented Sep 22, 2023 at 14:01
  • Well, I've been told my approach won't work. How do I copy it from Magento properly then? What should I change in the native code to make it work in the popup?
    – Dramorian
    Commented Sep 25, 2023 at 10:54

1 Answer 1


I use getContent in my phtml template

Try once this code :-

<div id="modal-content">
    <?php echo $this->getContent(); ?>

echo this->getLayout()->createBlock("Magento\Customer\Block\Form\Register")->setTemplate("Magento_Customer::form/register.phtml")->toHtml();
  • I tried this approach already. When I go to the page I see raw HTML only with error stack trace. The only solution is to completely copy-paste the existing form into my popup. That's the issue.
    – Dramorian
    Commented Sep 25, 2023 at 12:39

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.