You are here

function responsive_tables_filter_preprocess_field in Responsive Tables Filter 7

Implements hook_preprocess_field().

File

./responsive_tables_filter.module, line 187
Make tables responsive, when filter is enabled for the field.

Code

function responsive_tables_filter_preprocess_field(&$variables) {
  $field_type = $variables['element']['#field_type'];
  switch ($field_type) {
    case 'tablefield':
      if (isset($variables['items'])) {

        // Account for field deltas.
        foreach ($variables['items'] as &$item) {
          $item['#attributes']['class'][] = 'tablesaw';
          $item['#attributes']['class'][] = 'tablesaw-stack';
          $item['#attributes']['data-tablesaw-mode'] = 'stack';
        }
      }
      break;
  }
}