I’m trying to add a captcha to a custom form that I created in a CMS page in Magento. The captcha is working correctly on the default Contact Us page, but it’s not refreshing every time on my custom form.
Here’s how I’m currently calling the captcha block in my CMS page’s theme PHTML file:
<?php
/**
* @var MagentoCaptchaBlockCaptcha $captchaBlock
*/
$captchaBlock = $block->getLayout()->createBlock(MagentoCaptchaBlockCaptchaDefaultCaptcha::class);
$captchaBlock->setTemplate("Magento_Captcha::default.phtml");
$captchaBlock->setFormId("contact_us");
echo $captchaBlock->toHtml();
?>
The issue is that the captcha is not refreshing properly on my custom form. It works fine on the Contact Us page, but not on my custom form.
Any insights into why the captcha isn’t refreshing correctly on my custom form would be greatly appreciated. Thank you!