public function Captcha::form in YAML Form 8
Gets the actual configuration form array to be built.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array An associative array contain the element's configuration form without any default values..
Overrides YamlFormElementBase::form
File
- src/
Plugin/ YamlFormElement/ Captcha.php, line 89
Class
- Captcha
- Provides a 'captcha' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
if (\Drupal::moduleHandler()
->moduleExists('captcha')) {
module_load_include('inc', 'captcha', 'captcha.admin');
$captcha_types = _captcha_available_challenge_types();
}
else {
$captcha_types = [
'default' => $this
->t('Default challenge type'),
];
}
$form['captcha'] = [
'#type' => 'fieldset',
'#title' => $this
->t('CAPTCHA settings'),
];
$form['captcha']['captcha_type'] = [
'#type' => 'select',
'#title' => $this
->t('Challenge type'),
'#required' => TRUE,
'#options' => $captcha_types,
];
$form['captcha']['captcha_admin_mode'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Admin mode'),
'#description' => $this
->t('Presolve the CAPTCHA and always shows it. This is useful for debugging and preview CAPTCHA integration.'),
'#return_value' => TRUE,
];
return $form;
}