function hook_element_info_alter

Same name in other branches
  1. 7.x modules/system/system.api.php \hook_element_info_alter()
  2. 9 core/lib/Drupal/Core/Render/theme.api.php \hook_element_info_alter()
  3. 8.9.x core/lib/Drupal/Core/Render/theme.api.php \hook_element_info_alter()
  4. 10 core/lib/Drupal/Core/Render/theme.api.php \hook_element_info_alter()

Alter the element type information returned from modules.

A module may implement this hook in order to alter the element type defaults defined by a module.

Parameters

array $info: An associative array with structure identical to that of the return value of \Drupal\Core\Render\ElementInfoManagerInterface::getInfo().

See also

\Drupal\Core\Render\ElementInfoManager

\Drupal\Core\Render\Element\ElementInterface

Related topics

4 functions implement hook_element_info_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

claro_element_info_alter in core/themes/claro/claro.theme
Implements hook_element_info_alter().
element_info_test_element_info_alter in core/modules/system/tests/modules/element_info_test/element_info_test.module
Implements hook_element_info_alter().
olivero_element_info_alter in core/themes/olivero/olivero.theme
Implements hook_element_info_alter().
test_theme_element_info_alter in core/modules/system/tests/themes/test_theme/test_theme.theme
Implements hook_element_info_alter().
1 invocation of hook_element_info_alter()
ElementInfoManager::buildInfo in core/lib/Drupal/Core/Render/ElementInfoManager.php
Builds up all element information.

File

core/lib/Drupal/Core/Render/theme.api.php, line 855

Code

function hook_element_info_alter(array &$info) {
    // Decrease the default size of textfields.
    if (isset($info['textfield']['#size'])) {
        $info['textfield']['#size'] = 40;
    }
}

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