Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / inline_form_errors / src / FormErrorHandler.php
index 2b892e99dd6845521970cf7b106bd2f7b44fa7a7..2bcbfc60be7f2fc37611f6e425fbebc70e221231 100644 (file)
@@ -47,15 +47,23 @@ class FormErrorHandler extends CoreFormErrorHandler {
   /**
    * Loops through and displays all form errors.
    *
+   * To disable inline form errors for an entire form set the
+   * #disable_inline_form_errors property to TRUE on the top level of the $form
+   * array:
+   * @code
+   * $form['#disable_inline_form_errors'] = TRUE;
+   * @endcode
+   * This should only be done when another appropriate accessibility strategy is
+   * in place.
+   *
    * @param array $form
    *   An associative array containing the structure of the form.
    * @param \Drupal\Core\Form\FormStateInterface $form_state
    *   The current state of the form.
    */
   protected function displayErrorMessages(array $form, FormStateInterface $form_state) {
-    // Use the original error display for Quick Edit forms, because in this case
-    // the errors are already near the form element.
-    if ($form['#form_id'] === 'quickedit_field_form') {
+    // Skip generating inline form errors when opted out.
+    if (!empty($form['#disable_inline_form_errors'])) {
       parent::displayErrorMessages($form, $form_state);
       return;
     }