public function SecuritytxtConfigureForm::validateForm in Security.txt 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
- src/
Form/ SecuritytxtConfigureForm.php, line 136
Class
- SecuritytxtConfigureForm
- Configure the security.txt file.
Namespace
Drupal\securitytxt\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$enabled = $form_state
->getValue('enabled');
$contact_email = $form_state
->getValue('contact_email');
$contact_phone = $form_state
->getValue('contact_phone');
$contact_url = $form_state
->getValue('contact_url');
/* When enabled, check that at least one contact field is specified. */
if ($enabled && $contact_email == '' && $contact_phone == '' && $contact_url == '') {
$form_state
->setErrorByName('contact', $this
->t('You must specify at least one method of contact.'));
}
}