8.5.x field.api.php hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode)
8.0.x field.api.php hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode)
8.1.x field.api.php hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode)
8.2.x field.api.php hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode)
8.3.x field.api.php hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode)
8.4.x field.api.php hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode)
8.6.x field.api.php hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode)
7.x field.api.php hook_field_info_max_weight($entity_type, $bundle, $context)

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

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

$bundle: The bundle name.

$context: The context for which the maximum weight is requested. Either 'form', or the name of a view mode.

Return value

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()
field_info_max_weight in modules/field/field.info.inc
Returns the maximum weight of all the components in an entity.

File

modules/field/field.api.php, line 2327
Hooks provided by the Field module.

Code

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