Fichier
-
src/
Form/ SpambotUserspamForm.php, line 276
Classe
- SpambotUserspamForm
- Settings form to save the configuration for Spambot.
Namespace
Drupal\spambot\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->getValues();
$key_required = !empty($values['report']['nids']) && count(array_filter($values['report']['nids']));
if ($comments_enabled = $this->moduleHandler
->moduleExists('comment')) {
$key_required = !empty($values['report']['cids']) && count(array_filter($values['report']['cids'])) || $key_required;
}
if ($key_required && !$this->config
->get('spambot_sfs_api_key')) {
$form_state->setErrorByName('action', $this->t('To report spammers to www.stopforumspam.com, you need to register for an API key at <a href="https://www.stopforumspam.com">www.stopforumspam.com</a> and enter it into the @page.', [
'@page' => Link::fromTextAndUrl($this->t('spambot settings'), Url::fromRoute('spambot.settings_form'))
->toString(),
]));
}
}