Thanks for the detailed response. I've been trying for several days but I'm not doing something right. My configuration is:
- Plugin CAPTCHA - Google Invisible reCAPTCHA: Active with Site and Secret keys.
- Global configuration > Default Captcha: CAPTCHA - Google Invisible reCAPTCHA
- In default.php: before </form>
<php echo $this->captcha?->display('captcha') ?? '';
- In Model after loadFormData():
public function isCAPTCHAValid(): bool
{
$input = \Joomla\CMS\Factory::getApplication()->input;
return $this->getCAPTCHAObject()?->checkAnswer($input->get('captcha', '', 'raw')) ?? true; //
I think there is a parenthesis left over in your original code
}
And in Model and HtmlView the getCAPTCHAObject() function, a little modified to see parameter object:
public function getCAPTCHAObject(): ?\Joomla\CMS\Captcha\Captcha
{
// Get the default CAPTCHA plugin from the application's configuration.
$params = Factory::getApplication()->getParams();
echo '<pre>Params: ', print_r($params), '</pre>';
$plugin = Factory::getApplication()->getParams()->get('captcha', '');
return empty($plugin)
? null
: \Joomla\CMS\Captcha\Captcha::getInstance($plugin, ['namespace' => 'com_formularios']);
}
And I get this object where no captcha property is present:
Params: Joomla\Registry\Registry Object
(
[data:protected] => stdClass Object
(
[save_history] => 0
[history_limit] => 5
[sef_ids] => 0
[show_page_heading] => 0
[menu-anchor_css] => bg-danger text-white fw-bold
[menu_text] => 1
[menu_show] => 1
[page_title] => My title
[helixultimate_enable_page_title] => 0
[helixultimate_page_title_heading] => h2
[page_description] => My page description
[page_rights] =>
[robots] => noindex, nofollow
)
[initialized:protected] => 1
[separator:protected] => .
)