public function ImageCaptchaSettingsForm::submitForm in CAPTCHA 8
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides ConfigFormBase::submitForm
File
- image_captcha/
src/ Form/ ImageCaptchaSettingsForm.php, line 301
Class
- ImageCaptchaSettingsForm
- Displays the pants settings form.
Namespace
Drupal\image_captcha\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$imageSettings = $form_state
->cleanValues()
->getValues();
if (!isset($form['image_captcha_font_settings']['no_ttf_support'])) {
// Filter the image_captcha fonts array to pick out the selected ones.
$image_captcha_fonts = $form_state
->getValue('image_captcha_fonts');
$imageSettings['image_captcha_fonts'] = array_filter($imageSettings['image_captcha_fonts']);
}
$config = $this
->config('image_captcha.settings');
// Exclude few fields from config.
$exclude = [
'image',
'captcha_sid',
'captcha_token',
'captcha_response',
];
foreach ($imageSettings as $configName => $configValue) {
if (!in_array($configName, $exclude)) {
$config
->set($configName, $configValue);
}
}
$config
->save();
parent::SubmitForm($form, $form_state);
}