class InlineFormErrorsThemeHooks

Same name and namespace in other branches
  1. main core/modules/inline_form_errors/src/Hook/InlineFormErrorsThemeHooks.php \Drupal\inline_form_errors\Hook\InlineFormErrorsThemeHooks

Hook implementations for inline_form_errors.

Hierarchy

Expanded class hierarchy of InlineFormErrorsThemeHooks

File

core/modules/inline_form_errors/src/Hook/InlineFormErrorsThemeHooks.php, line 10

Namespace

Drupal\inline_form_errors\Hook
View source
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'];
    }
  }

}

Members

Title Sort descending Modifiers Object type Summary
InlineFormErrorsThemeHooks::preprocessDatetimeWrapper public function Implements hook_preprocess_HOOK() for datetime form wrapper templates.
InlineFormErrorsThemeHooks::preprocessDetails public function Implements hook_preprocess_HOOK() for details element templates.
InlineFormErrorsThemeHooks::preprocessFieldset public function Implements hook_preprocess_HOOK() for fieldset element templates.
InlineFormErrorsThemeHooks::preprocessFormElement public function Implements hook_preprocess_HOOK() for form element templates.
InlineFormErrorsThemeHooks::setErrors protected function Populates form errors in the template.

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