FooCaptchaSettingsForm.php in CAPTCHA Pack 8
File
foo_captcha/src/Form/FooCaptchaSettingsForm.php
View source
<?php
namespace Drupal\foo_captcha\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class FooCaptchaSettingsForm extends ConfigFormBase {
public function getFormId() {
return 'foo_captcha_settings';
}
protected function getEditableConfigNames() {
return [
'foo_captcha.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('foo_captcha.settings');
$form = [];
$form['foo_captcha_ignore_spaces'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Ignore spaces in the response'),
'#default_value' => $config
->get('foo_captcha_ignore_spaces'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('foo_captcha.settings')
->set('foo_captcha_ignore_spaces', $form_state
->getValue('foo_captcha_ignore_spaces'))
->save();
parent::SubmitForm($form, $form_state);
}
}