0

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">
 <body>
 <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" />
 </referenceBlock>
 </body>
 </page>

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(); ?>
</div>
asked Sep 22, 2023 at 12:31
3
  • Create popup in Magento : integerbyteblog.in/magento/… Commented Sep 22, 2023 at 13:41
  • 1
    I have a popup already... 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? Commented Sep 25, 2023 at 10:54

1 Answer 1

0

I use getContent in my phtml template

Try once this code :-

<div id="modal-content">
 <?php echo $this->getContent(); ?>
 <?php 
echo this->getLayout()->createBlock("Magento\Customer\Block\Form\Register")->setTemplate("Magento_Customer::form/register.phtml")->toHtml();
 ?>
answered Sep 25, 2023 at 12:16
1
  • 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. Commented Sep 25, 2023 at 12:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.