cancel
Showing results for 
Search instead for 
Did you mean: 

MSP reCaptcha not showing in BLOCK register.phtml

MSP reCaptcha not showing in BLOCK register.phtml

Hello,

 

on the standard register-page customer/account/create/ everything works fine, msp_recaptcha is shown.

 

But: I need to show register-page in a modal, so i build my modal by using registerpage-block to get the content:

$this->getLayout()->createBlock("Magento\Customer\Block\Form\Register")->setTemplate("Magento_Customer::form/register.phtml")->toHtml();

There no recaptcha is shown Smiley Sad

 

When i try to insert recaptcha also like a block with:

$this->getLayout()->createBlock("MSP\ReCaptcha\Block\Frontend\ReCaptcha")->setTemplate("MSP_ReCaptcha::msp_recaptcha.phtml")->toHtml();

Then only the "empty" recaptcha-DIV is shown:

<div class="field-recaptcha" id="msp-recaptcha-c4f8b6edf65ed298fb0a73-container" data-bind="scope:'msp-recaptcha-4f8b6edf65ed298fb0a73'">
    <!-- ko template: getTemplate() --><!-- /ko -->
</div>

Why is the recaptcha functionality not loaded correctly, when i use registerpage as block?

How can i achieve this?

 

Thank you

4 REPLIES 4

Re: MSP reCaptcha not showing in BLOCK register.phtml

Hello? Nobody?

Re: MSP reCaptcha not showing in BLOCK register.phtml

Everything functions as expected on the regular register page, customer/account/create/, and msp recaptcha is displayed.

Re: MSP reCaptcha not showing in BLOCK register.phtml

I dont know why you write this?

Have you even read my post?

 

Its all about showing the registrationpage in a popup / modal, by including the registration as block!

But there no reCaptcha is shown and i asked, how i can make this work.

 

Of course everything works well on the normal page for registration, but i did not ask for that.

Re: MSP reCaptcha not showing in BLOCK register.phtml

I found the solution by myself after days:

 

echo $this->getLayout()
    ->createBlock('MSP\ReCaptcha\Block\Frontend\ReCaptcha',
        'msp-recaptcha',
        ['data' =>
            [
                'jsLayout' =>
                    [
                        'components' =>
                            [
                                'msp-recaptcha' =>
                                    [
                                        'component' => 'MSP_ReCaptcha/js/reCaptcha',
                                        'reCaptchaId' => 'msp-recaptcha',
                                        'zone' => 'create'
                                    ]
                            ]
                    ]
            ]
        ]
    )
    ->setTemplate('MSP_ReCaptcha::msp_recaptcha.phtml')
    ->toHtml();