namespace Drupal\Core\Form;
use Drupal\Component\Utility\NestedArray;
+use Drupal\Core\Messenger\MessengerTrait;
use Drupal\Core\Render\Element;
/**
*/
class FormErrorHandler implements FormErrorHandlerInterface {
+ use MessengerTrait;
+
/**
* {@inheritdoc}
*/
// Loop through all form errors and set an error message.
foreach ($errors as $error) {
- $this->drupalSetMessage($error, 'error');
+ $this->messenger()->addMessage($error, 'error');
}
}
* Grouping example:
* Assume you have a 'street' element somewhere in a form, which is displayed
* in a details element 'address'. It might be:
+ *
* @code
* $form['street'] = [
* '#type' => 'textfield',
$elements['#errors'] = $form_state->getError($elements);
}
- /**
- * Wraps drupal_set_message().
- *
- * @codeCoverageIgnore
- */
- protected function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) {
- drupal_set_message($message, $type, $repeat);
- }
-
}