Skip to content
Snippets Groups Projects

Add validation message to the form for Drupal 10.2 and above

@@ -124,10 +124,19 @@ final class ViewedDeleteForm implements ContainerInjectionInterface {
if ($relations->hasRelationsWithStatus('valid')) {
if ($this->getIntegrityValidationMode() == IntegritySettingsForm::BLOCK_MODE) {
$form['actions']['submit']['#disabled'] = TRUE;
$this->messenger->addError($this->getMessage($relations));
if (version_compare(\Drupal::VERSION, '10.2', '>=')) {
$form['messages'] = $this->getMessage($relations);
} else {
$this->messenger->addError($this->getMessage($relations));
}
}
else {
$this->messenger->addWarning($this->getMessage($relations));
if (version_compare(\Drupal::VERSION, '10.2', '>=')) {
$form['messages'] = $this->getMessage($relations);
} else {
$this->messenger->addWarning($this->getMessage($relations));
}
}
}
}
Loading