You are here

function multifield_table_pre_render_field in Multifield table 7

Callback for #pre_render for a single row, hide the titles for each field.

1 call to multifield_table_pre_render_field()
multifield_table_pre_render_multiple_fields in ./multifield_table.module
Callback for #pre_render for multiple rows, hide the titles for each field.

File

./multifield_table.module, line 186
Provides a table formatter and widget for multifield field types.

Code

function multifield_table_pre_render_field($element) {
  $multifield_info = field_info_field($element['#field_name']);
  foreach (multifield_type_get_subfields($multifield_info['type']) as $field_name) {
    if (empty($element[$field_name])) {
      continue;
    }
    $field =& $element[$field_name];
    $field_info = field_info_field($field_name);
    $language = $field['#language'];
    if (isset($field[$language])) {

      // Set the most common places for a title to display invisible.
      $field['#title_display'] = 'invisible';
      $field[$language]['#title_display'] = 'invisible';
      foreach (element_children($field[$language]) as $child) {
        $field[$language][$child]['#title_display'] = 'invisible';

        // Check the individual columns. Most commonly 'value'.
        foreach ($field_info['columns'] as $column => $column_info) {
          $field[$language][$child][$column]['#title_display'] = 'invisible';

          // The date module sometimes adds its own random titles inside value.
          if (in_array($field_info['type'], array(
            'date',
            'datestamp',
            'datetime',
          ))) {
            foreach (element_children($field[$language][$child][$column]) as $date_child) {
              $field[$language][$child][$column][$date_child]['#title_display'] = 'invisible';
            }
          }
        }
      }
    }
    else {
      $field['#label_display'] = 'hidden';
    }
  }
  return $element;
}