InlineFormErrorsThemeHooks.php
Same filename and directory in other branches
Namespace
Drupal\inline_form_errors\HookFile
-
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 {
/**
* Implements hook_theme().
*/
public function theme() : array {
return [
'inline_form_errors_summary' => [
'variables' => [
'error_links' => [],
'form_id' => NULL,
],
],
];
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
public function themeSuggestionsInlineFormErrorsSummary(array $variables) : array {
$suggestions = [];
if (!empty($variables['form_id'])) {
$suggestions[] = 'inline_form_errors_summary__' . $variables['form_id'];
}
return $suggestions;
}
/**
* 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.