You are here

function computed_field_field_info in Computed Field 7

Same name and namespace in other branches
  1. 5 computed_field.module \computed_field_field_info()
  2. 6 computed_field.module \computed_field_field_info()

Implements hook_field_info().

File

./computed_field.module, line 54
Functionality for the computed field.

Code

function computed_field_field_info() {
  return array(
    'computed' => array(
      'label' => t('Computed'),
      'description' => t('Create field data via PHP code.'),
      'settings' => array(
        'code' => '$entity_field[0][\'value\'] = "";',
        'display_format' => '$display_output = $entity_field_item[\'value\'];',
        'store' => 1,
        'recalculate' => FALSE,
        'database' => array(
          'data_type' => 'varchar',
          'data_length' => 32,
          'data_size' => 'normal',
          'data_precision' => 10,
          'data_scale' => 2,
          'data_not_NULL' => FALSE,
          'data_default' => NULL,
          'data_index' => FALSE,
        ),
      ),
      'default_widget' => 'computed',
      'default_formatter' => 'computed_field_plain',
      // If we followed the core convention of separate fields for each data
      // type we could make Entity API happy by just setting a property_type.
      // Instead we have to use our own callback to determine the type then
      // rerun theirs to setup the rest of the field properties.
      'property_callbacks' => array(
        'computed_field_entity_property_callback',
      ),
    ),
  );
}