public function PhraseCaptchaSettingsForm::validateForm in CAPTCHA Pack 8
Form validation 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 FormBase::validateForm
File
- text_captcha/
modules/ phrase_captcha/ src/ Form/ PhraseCaptchaSettingsForm.php, line 108
Class
- PhraseCaptchaSettingsForm
- Administration form.
Namespace
Drupal\phrase_captcha\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->getValue('phrase_captcha_words') == PHRASE_CAPTCHA_USER_DEFINED_WORDS) {
$word_count_minimum = $form_state
->getValue('phrase_captcha_word_quantity') + $form_state
->getValue('phrase_captcha_additional_word_quantity') + 2;
_text_captcha_word_pool_validate('phrase_captcha_userdefined_word_pool', $form_state, $word_count_minimum, NULL, NULL);
}
// Check word selection.
if (count(array_filter($form_state
->getValue('phrase_captcha_word_selection_challenges'))) < 1) {
$form_state
->setErrorByName('phrase_captcha_word_selection_challenges', $this
->t('You need to select at least one word selection criterium'));
}
parent::validateForm($form, $form_state);
}