W3cubDocs

/Drupal 8

function hook_element_info_alter

hook_element_info_alter(array &$info)

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

Hooks
Define functions that alter the behavior of Drupal core.

File

core/lib/Drupal/Core/Render/theme.api.php, line 798
Hooks and documentation related to the theme and render system.

Code

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/function/hook_element_info_alter/8.1.x