I have a custom field, that hooks into profile2 and saves it’s value in user data blob. Everything works fine, except the hook_field_formatter_view, that does not get called for a reason. As a result, when the field is viewed, it returns always an empty array. I have all declaration hooks in place.
<?php /** * Implementation of hook_field_info(). */ function profile_cal_field_info() { return array( 'profile_cal' => array( 'label' => t('Availability calendar'), 'description' => t('Sets weekly available time.'), 'default_widget' => 'profile_cal_cal', 'default_formatter' => 'profile_cal_formatter', ), ); } /** * Implements hook_field_formatter_info(). */ function profile_cal_field_formatter_info() { return array( 'profile_cal_formatter' => array( 'label' => t('Default'), 'field types' => array('profile_cal'), ), ); } /** * Implements hook_field_widget_info(). */ function profile_cal_field_widget_info() { return array( 'profile_cal_cal' => array( 'label' => t('Availability widget'), 'field types' => array('profile_cal'), 'multiple values' => FIELD_BEHAVIOR_DEFAULT, 'default value' => FIELD_BEHAVIOR_NONE, ), ); } /** * Implements hook_field_formatter_view(). */ function profile_cal_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { drupal_set_message('Called!'); $element = array(); return $element; } /** * Implements hook_field_is_empty(). */ function profile_cal_field_is_empty($item, $field) { return FALSE; } ?>
Sponsored by SupremePR