function hook_field_info_max_weight

Returns the maximum weight for the entity components handled by the module.

Field API takes care of fields and 'extra_fields'. This hook is intended for third-party modules adding other entity components (e.g. field_group).

Parameters

string $entity_type: The type of entity; e.g. 'node' or 'user'.

string $bundle: The bundle name.

string $context: The context for which the maximum weight is requested. Either 'form' or 'display'.

string $context_mode: The view or form mode name.

Return value

int The maximum weight of the entity's components, or NULL if no components were found.

Related topics

1 invocation of hook_field_info_max_weight()
EntityDisplayBase::getHighestWeight in drupal/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php
Returns the highest weight of the components in the display.

File

drupal/core/modules/field/field.api.php, line 1803

Code

function hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode) {
  $weights = array();
  foreach (my_module_entity_additions($entity_type, $bundle, $context, $context_mode) as $addition) {
    $weights[] = $addition['weight'];
  }
  return $weights ? max($weights) : NULL;
}