You are here

function auto_entitylabel_max_length in Automatic Entity Label 7

Function to extract the maximum length.

Tries to extract the maximum length for the given property from the respective database schema field.

Assumes that the schema field is named identical to the property.

1 call to auto_entitylabel_max_length()
auto_entitylabel_set_title in ./auto_entitylabel.module
Sets the automatically generated entitylabel for the entity.

File

./auto_entitylabel.module, line 542
Allows hiding of entity label fields and automatic label creation.

Code

function auto_entitylabel_max_length($entity_type, $property_name) {

  // Load entity and schema info.
  $entity_info = entity_get_info($entity_type);
  $schema = drupal_get_schema($entity_info['base table']);

  // Return 'length' from schema field as maximum length, fall back to 255.
  return isset($schema['fields'][$property_name]['length']) ? $schema['fields'][$property_name]['length'] : 255;
}