public function DataPolicyAgreement::validateForm in Data Policy 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/ DataPolicyAgreement.php, line 183
Class
- DataPolicyAgreement
- Class DataPolicyAgreement.
Namespace
Drupal\data_policy\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$errors = $form_state
->getErrors();
if (!empty($errors)) {
$form_state
->clearErrors();
foreach ($errors as $id => $error) {
/** @var \Drupal\Core\StringTranslation\TranslatableMarkup $g */
if (strpos($id, 'data_policy') !== FALSE) {
$name = Markup::create($error
->getArguments()['@name']);
$form_state
->setErrorByName($id, t('@name field is required.', [
'@name' => $name,
]));
continue;
}
$form_state
->setErrorByName($id, $error);
}
}
parent::validateForm($form, $form_state);
}