You are here

function starrating_field_attach_view_alter in Star Rating 7.2

Implements hook_field_attach_view_alter().

Alter the output to include "items" on null valued fields to allow the "No rating" text to come through. Otherwise it would not be displayed

File

./starrating.module, line 227
Provides star rating field, formatter and widget using Field API. star rating field is based on integer value and convert it to the HTML code that displays series of icons. The formatter supports not only star rating field type but also…

Code

function starrating_field_attach_view_alter(&$output, $context) {
  foreach (element_children($output) as $field_name) {
    if ($output[$field_name]['#field_type'] == 'list_integer') {
      if (empty($output[$field_name]['#items'])) {
        $output[$field_name]['#items'] = array(
          array(
            'value' => NULL,
          ),
        );
      }
    }
  }
}