You are here

function phone_field_property_info_callback in Phone 7.2

Additional callback to adapt the property info of phone fields.

See also

entity_metadata_field_entity_property_info()

1 string reference to 'phone_field_property_info_callback'
phone_field_info in ./phone.module
Implements hook_field_info().

File

./phone.module, line 216
The phone module lets administrators use a phone number field type.

Code

function phone_field_property_info_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';
  $property['type'] = $field['cardinality'] != 1 ? 'list<field_item_phone>' : 'field_item_phone';

  // Auto-create the field item as soon as a property is set.
  $property['auto creation'] = 'phone_field_item_create';
  $property['property info'] = array(
    'numbertype' => array(
      'type' => 'text',
      'label' => t('The phone number type id. e.g work, home'),
      'required' => TRUE,
      'setter callback' => 'entity_property_verbatim_set',
      'entity views field' => TRUE,
    ),
    'numbertypelabel' => array(
      'type' => 'text',
      'label' => t('The phone number type label. e.g Work, Home'),
      'required' => TRUE,
      'schema field' => 'numbertype',
      'options list' => 'phone_field_property_numbertype_options',
      'entity views field' => TRUE,
    ),
    'number' => array(
      'type' => 'text',
      'label' => t('The phone number as entered'),
      'required' => TRUE,
      'setter callback' => 'entity_property_verbatim_set',
      'entity views field' => TRUE,
    ),
    'countrycode' => array(
      'type' => 'text',
      'label' => t('The two letter ISO country code'),
      'setter callback' => 'entity_property_verbatim_set',
      'entity views field' => TRUE,
    ),
    'callingcode' => array(
      'type' => 'integer',
      'label' => t('The country calling code.'),
      'getter callback' => 'phone_field_property_get_callingcode',
      'entity views field' => TRUE,
    ),
    'countryname' => array(
      'type' => 'text',
      'label' => t('The country calling code.'),
      'getter callback' => 'entity_property_verbatim_get',
      'entity views field' => TRUE,
      'schema field' => 'countrycode',
      'options list' => 'phone_field_property_country_options',
    ),
    'extension' => array(
      'type' => 'text',
      'label' => t('The extension'),
      'setter callback' => 'entity_property_verbatim_set',
      'entity views field' => TRUE,
    ),
  );
  unset($property['query callback']);
}