diff --git a/core/lib/Drupal/Core/Form/FormBase.php b/core/lib/Drupal/Core/Form/FormBase.php index 42ec8be..3d5a8c0 100644 --- a/core/lib/Drupal/Core/Form/FormBase.php +++ b/core/lib/Drupal/Core/Form/FormBase.php @@ -49,6 +49,13 @@ protected $configFactory; /** + * The form error handler. + * + * @var \Drupal\Core\Form\FormErrorInterface + */ + protected $errorHandler; + + /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { @@ -214,4 +221,17 @@ protected function container() { return \Drupal::getContainer(); } + /** + * Returns the form error handler. + * + * @return \Drupal\Core\Form\FormErrorInterface + * The form error handler. + */ + protected function errorHandler() { + if (!$this->errorHandler) { + $this->errorHandler = \Drupal::service('form_builder'); + } + return $this->errorHandler; + } + } diff --git a/core/modules/dblog/lib/Drupal/dblog/Form/DblogFilterForm.php b/core/modules/dblog/lib/Drupal/dblog/Form/DblogFilterForm.php index 4e65859..201b192 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Form/DblogFilterForm.php +++ b/core/modules/dblog/lib/Drupal/dblog/Form/DblogFilterForm.php @@ -69,7 +69,7 @@ public function buildForm(array $form, array &$form_state) { */ public function validateForm(array &$form, array &$form_state) { if (empty($form_state['values']['type']) && empty($form_state['values']['severity'])) { - form_set_error('type', $form_state, $this->t('You must select something to filter by.')); + $this->errorHandler()->setErrorByName('type', $form_state, $this->t('You must select something to filter by.')); } }