Answers:
您可以创建一个自定义表单模板(基于原始模板),然后可以通过编程方式加载reCaptcha块,如下所示:
<?php
echo $block->getLayout()
->createBlock('MSP\ReCaptcha\Block\Frontend\ReCaptcha',
'msp-recaptcha',
['data' =>
[
'jsLayout' =>
[
'components' =>
[
'msp-recaptcha' =>
[
'component' => 'MSP_ReCaptcha/js/reCaptcha',
'zone' => 'contact'
]
]
]
]
]
)
->setTemplate('MSP_ReCaptcha::msp_recaptcha.phtml')
->toHtml();
?>