You are here

function recipe_metadata_field_ingredient_property_callback in Recipe 7.2

Callback to alter the property info of ingredient fields.

See also

recipe_field_info()

1 string reference to 'recipe_metadata_field_ingredient_property_callback'
recipe_field_info in ./recipe.module
Implements hook_field_info().

File

./recipe.module, line 803
Contains functions for Recipe node CRUD and display.

Code

function recipe_metadata_field_ingredient_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']);
  $property['type'] = $field['cardinality'] != 1 ? 'list<struct>' : 'struct';
  $property['getter callback'] = 'entity_metadata_field_verbatim_get';
  $property['setter callback'] = 'entity_metadata_field_verbatim_set';
  $property['property info'] = array(
    'ingredient' => array(
      'type' => 'text',
      'label' => t('Ingredient'),
      'getter callback' => 'recipe_metadata_field_ingredient_name_get',
      'setter callback' => 'recipe_metadata_field_ingredient_name_set',
      'required' => TRUE,
    ),
    'quantity' => array(
      'type' => 'decimal',
      'label' => t('Quantity'),
      'setter callback' => 'entity_property_verbatim_set',
    ),
    'unit' => array(
      'type' => 'token',
      'label' => t('Quantity units'),
      'options list' => 'recipe_metadata_field_ingredient_units',
      'getter callback' => 'recipe_metadata_field_ingredient_unit_get',
      'setter callback' => 'recipe_metadata_field_ingredient_unit_set',
    ),
    'note' => array(
      'type' => 'text',
      'label' => t('Preparation notes'),
      'setter callback' => 'entity_property_verbatim_set',
    ),
  );
}