public function Captcha::preview in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/Captcha.php \Drupal\webform\Plugin\WebformElement\Captcha::preview()
Generate a renderable preview of the element.
Return value
array A renderable preview of the element.
Overrides WebformElementBase::preview
File
- src/
Plugin/ WebformElement/ Captcha.php, line 127
Class
- Captcha
- Provides a 'captcha' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function preview() {
$element = parent::preview() + [
'#captcha_admin_mode' => TRUE,
// Define empty form id to prevent fatal error when preview is
// rendered via Ajax.
// @see \Drupal\captcha\Element\Captcha::processCaptchaElement
'#captcha_info' => [
'form_id' => '',
],
];
if ($this->moduleHandler
->moduleExists('image_captcha')) {
$element['#captcha_type'] = 'image_captcha/Image';
}
return $element;
}