InlineFormErrorsThemeHooks.php

Same filename and directory in other branches
  1. 11.x core/modules/inline_form_errors/src/Hook/InlineFormErrorsThemeHooks.php

Namespace

Drupal\inline_form_errors\Hook

File

core/modules/inline_form_errors/src/Hook/InlineFormErrorsThemeHooks.php

View source
<?php

namespace Drupal\inline_form_errors\Hook;

use Drupal\Core\Hook\Attribute\Hook;

/**
 * Hook implementations for inline_form_errors.
 */
class InlineFormErrorsThemeHooks {
  
  /**
   * @file
   */

  
  /**
   * Implements hook_preprocess_HOOK() for form element templates.
   */
  public function preprocessFormElement(&$variables) : void {
    $this->setErrors($variables);
  }
  
  /**
   * Implements hook_preprocess_HOOK() for details element templates.
   */
  public function preprocessDetails(&$variables) : void {
    $this->setErrors($variables);
  }
  
  /**
   * Implements hook_preprocess_HOOK() for fieldset element templates.
   */
  public function preprocessFieldset(&$variables) : void {
    $this->setErrors($variables);
  }
  
  /**
   * Implements hook_preprocess_HOOK() for datetime form wrapper templates.
   */
  public function preprocessDatetimeWrapper(&$variables) : void {
    $this->setErrors($variables);
  }
  
  /**
   * Populates form errors in the template.
   */
  protected function setErrors(&$variables) : void {
    $element = $variables['element'];
    if (!empty($element['#errors']) && empty($element['#error_no_message'])) {
      $variables['errors'] = $element['#errors'];
    }
  }

}

Classes

Title Deprecated Summary
InlineFormErrorsThemeHooks Hook implementations for inline_form_errors.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.