public function Captcha::prepare in YAML Form 8
Prepare an element to be rendered within a form.
Parameters
array $element: An element.
\Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission: A form submission.
Overrides YamlFormElementBase::prepare
File
- src/
Plugin/ YamlFormElement/ Captcha.php, line 60
Class
- Captcha
- Provides a 'captcha' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
// Enable admin mode for test or user with 'skip CAPTCHA' permission.
$is_test = strpos(\Drupal::routeMatch()
->getRouteName(), '.yamlform.test') !== FALSE ? TRUE : FALSE;
$is_admin = \Drupal::currentUser()
->hasPermission('skip CAPTCHA');
if ($is_test || $is_admin) {
$element['#captcha_admin_mode'] = TRUE;
}
parent::prepare($element, $yamlform_submission);
}