You are here

function tablefield_field_formatter_settings_form in TableField 7.2

Same name and namespace in other branches
  1. 7.3 tablefield.module \tablefield_field_formatter_settings_form()

Implements hook_field_formatter_settings_form().

File

./tablefield.module, line 463
Provides a set of fields that can be used to store tabular data with a node.

Code

function tablefield_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();
  switch ($display['type']) {
    case 'format_raw':
      $element['usearraykeys'] = array(
        '#type' => 'select',
        '#title' => t('Use first row/column values as array keys (if not empty)'),
        '#options' => array(
          'No' => t('No'),
          'Header' => t('Header only'),
          'Both' => t('Both first row and first column (two headers, horizontal and vertical)'),
        ),
        '#default_value' => $settings['usearraykeys'],
      );
      $element['vertheader'] = array(
        '#title' => t('Vertical header (first column instead of first row)'),
        '#type' => 'checkbox',
        '#default_value' => $settings['vertheader'],
      );
      $element['tabledataonly'] = array(
        '#title' => t('Table data only (no caption)'),
        '#type' => 'checkbox',
        '#default_value' => $settings['tabledataonly'],
      );
      break;
    default:
      $element['sticky_header'] = array(
        '#title' => t('Sticky header'),
        '#type' => 'checkbox',
        '#default_value' => $settings['sticky_header'],
      );
      $element['hide_header'] = array(
        '#title' => t('Hide table header row'),
        '#type' => 'checkbox',
        '#default_value' => $settings['hide_header'],
      );
      $element['hide_cols_skip_head'] = array(
        '#title' => t('Hide empty columns ignoring column header'),
        '#type' => 'checkbox',
        '#default_value' => $settings['hide_cols_skip_head'],
      );
      $element['trim_trailing_cols'] = array(
        '#title' => t('Trim empty trailing columns'),
        '#type' => 'checkbox',
        '#default_value' => $settings['trim_trailing_cols'],
      );
      $element['trim_trailing_rows'] = array(
        '#title' => t('Trim empty trailing rows'),
        '#type' => 'checkbox',
        '#default_value' => $settings['trim_trailing_rows'],
      );
      $element['hide_empty_rows'] = array(
        '#title' => t('Hide empty rows'),
        '#type' => 'checkbox',
        '#default_value' => $settings['hide_empty_rows'],
      );
      $element['hide_empty_cols'] = array(
        '#title' => t('Hide empty columns'),
        '#type' => 'checkbox',
        '#default_value' => $settings['hide_empty_cols'],
      );
      $element['hide_cols_skip_head'] = array(
        '#title' => t('Hide empty columns ignoring column header'),
        '#type' => 'checkbox',
        '#default_value' => $settings['hide_cols_skip_head'],
      );
      $permission = l(t('permission'), 'admin/people/permissions', array(
        'fragment' => 'module-tablefield',
        'attributes' => array(
          'title' => t('Manage user permissions'),
        ),
      ));
      $element['export_csv'] = array(
        '#title' => t('Show link to export table data as CSV depending on !permission', array(
          '!permission' => $permission,
        )),
        '#type' => 'checkbox',
        '#default_value' => $settings['export_csv'],
      );
  }
  return $element;
}