hook_field_info_max_weight($entity_type, $bundle, $context, $context_mode)
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
- Hooks
- Define functions that alter the behavior of Drupal core.
File
- core/modules/field/field.api.php, line 259
- Field API documentation.
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; }
Please login to continue.