diff --git a/core/includes/form.inc b/core/includes/form.inc index c1f5620..9ff0e2b 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -354,14 +354,12 @@ function template_preprocess_form(&$variables) { if (!empty($element['#errors'])) { $error_links = []; - $error_titles = []; // Loop through all form errors, and display a link for each error that // is associated with a visible form element. foreach ($element['#errors'] as $key => $error) { if (($form_element = FormElementHelper::getElementByName($key, $element)) && Element::isVisibleElement($form_element)) { $title = FormElementHelper::getElementTitle($form_element); - $error_links['@' . $key] = \Drupal::l('@' . $key, Url::fromRoute('', [], ['fragment' => 'edit-' . str_replace('_', '-', $key), 'external' => TRUE])); - $error_titles['@' . $key] = $title; + $error_links[] = \Drupal::l($title, Url::fromRoute('', [], ['fragment' => 'edit-' . str_replace('_', '-', $key), 'external' => TRUE])); } else { drupal_set_message($error, 'error'); @@ -371,8 +369,9 @@ function template_preprocess_form(&$variables) { if (!empty($error_links)) { // We need to pass this through String::format() so drupal_set_message() // doesn't encode the links. - $message = \Drupal::translation()->formatPlural(count($error_links), '1 error has been found', '@count errors have been found') . ': ' . implode(', ', $error_links); - $message = String::format($message, $error_titles); + $message = \Drupal::translation()->formatPlural(count($error_links), '1 error has been found: @errors', '@count errors have been found: !errors', [ + '!errors' => implode(', ', $error_links), + ]); drupal_set_message($message, 'error'); } }