Created
March 5, 2013 08:25
-
-
Save dyslabpro/5088788 to your computer and use it in GitHub Desktop.
Revisions
-
dyslabpro created this gist
Mar 5, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ <?php /** * Implements hook_field_formatter_info(). */ function custom_content_management_field_formatter_info() { return array( 'custom_boolean' => array( 'label' => t('Custom boolean'), 'field types' => array('list_boolean'), ), ); } /** * Implements hook_field_formatter_view(). */ function custom_content_management_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); switch ($display['type']) { case 'custom_boolean': $allowed_values = list_allowed_values($field, $instance, $entity_type, $entity); foreach ($items as $delta => $item) { //Check if empty if(empty($allowed_values[$item['value']])){ continue; } if (isset($allowed_values[$item['value']])) { $output = field_filter_xss($allowed_values[$item['value']]); } else { // If no match was found in allowed values, fall back to the key. $output = field_filter_xss($item['value']); } $element[$delta] = array('#markup' => $output); } break; } return ((count($element)) ? $element : FALSE); }