You are here

function dimension_field_dimension_property_callback in Dimension 7

Additional callback to adapt the property info for dimension fields.

See also

entity_metadata_field_entity_property_info()

entity_field_info_alter()

1 string reference to 'dimension_field_dimension_property_callback'
dimension_field_info in ./dimension.module
Implements hook_field_info();

File

./dimension.module, line 37

Code

function dimension_field_dimension_property_callback(&$info, $entity_type, $field, $instance, $field_type) {
  $property =& $info[$entity_type]['bundles'][$instance['bundle']]['properties'][$field['field_name']];
  $property['getter callback'] = 'entity_metadata_field_verbatim_get';
  $property['setter callback'] = 'entity_metadata_field_verbatim_set';
  unset($property['query callback']);
  list($has_length, $has_more) = _dimension_get_modes($field['settings']['mode']);
  if ($has_length) {
    $property['property info']['length'] = array(
      'type' => 'integer',
      'label' => t('Length'),
      'setter callback' => 'entity_property_verbatim_set',
    );
  }
  if ($has_more) {
    $property['property info']['width'] = array(
      'type' => 'integer',
      'label' => t('Width'),
      'setter callback' => 'entity_property_verbatim_set',
    );
    $property['property info']['height'] = array(
      'type' => 'integer',
      'label' => t('Height'),
      'setter callback' => 'entity_property_verbatim_set',
    );
  }
}