0

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; } ?> 
1
  • may be clearing the caches may help! Commented Oct 1, 2013 at 10:40

1 Answer 1

0

Your code is correct, I just tested it and it works for me. I created fresh Drupal instance, created profile_cal module with your code without any modifications then added 'Availability calendar' field to 'Basic page' content type, created a page and got "Called!" message on the screen.

1
  • My thanks to you Pawel and Arpitr. Brobably, some settings in database got broken during development, and are now preventing the code form working properly. Thank you for testing it Pawel! Commented Oct 2, 2013 at 11:08

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.