function hook_field_info_alter

Same name and namespace in other branches
  1. 11.x core/modules/field/field.api.php \hook_field_info_alter()
  2. 9 core/modules/field/field.api.php \hook_field_info_alter()
  3. 10 core/modules/field/field.api.php \hook_field_info_alter()
  4. 8.9.x core/modules/field/field.api.php \hook_field_info_alter()

Perform alterations on Field API field types.

Parameters

$info: Array of information on field types exposed by hook_field_info() implementations.

Related topics

4 functions implement hook_field_info_alter()

Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.

ContentTranslationHooks::fieldInfoAlter in core/modules/content_translation/src/Hook/ContentTranslationHooks.php
Implements hook_field_info_alter().
EntityTypeInfo::fieldInfoAlter in core/modules/workspaces/src/Hook/EntityTypeInfo.php
Implements hook_field_info_alter().
LanguageHooks::fieldInfoAlter in core/modules/language/src/Hook/LanguageHooks.php
Implements hook_field_info_alter().
user_field_info_alter in modules/user/user.module
Implements hook_field_info_alter().

File

modules/field/field.api.php, line 196

Code

function hook_field_info_alter(&$info) {
  // Add a setting to all field types.
  foreach ($info as $field_type => $field_type_info) {
    $info[$field_type]['settings'] += array(
      'mymodule_additional_setting' => 'default value',
    );
  }
  // Change the default widget for fields of type 'foo'.
  if (isset($info['foo'])) {
    $info['foo']['default widget'] = 'mymodule_widget';
  }
}

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