Magento 2: How to add block inside block html content through XML file
-
19-02-2021 - |
Question
I have created my custom arithmetic captcha. I want add that captcha to my custom form through xml file without defining in phtml file on custom layout. For example:
Testimonail submit form: testimonial_form.phtml file contains
<form name="testimonial" action="testimonial/post/index" method="post">
<input type="text" name="name" />
<!-- I want captcha here through XML --!-->
<input type="submit" value="submit" />
</form>
I want to add my custom captcha through xml before th submit button. How can i do that?
Any help would be appreciated.
Solution
Create a container for that. You can check here, how to create that
Now you can use it inside your phtml:
<?= $block->getChildHtml('form.additional.info') ?>
Your configuration is done. Now you can add separate XML with name form.additional.info for captcha.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange