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>
- 
 Create popup in Magento : integerbyteblog.in/magento/…MP Raj– MP Raj2023年09月22日 13:41:05 +00:00Commented Sep 22, 2023 at 13:41
- 
 1I have a popup already...Dramorian– Dramorian2023年09月22日 14:01:12 +00:00Commented 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– Dramorian2023年09月25日 10:54:24 +00:00Commented 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(); ?>
 <?php 
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– Dramorian2023年09月25日 12:39:35 +00:00Commented Sep 25, 2023 at 12:39
Explore related questions
See similar questions with these tags.