You are here

protected function D3ViewsDataMapping::formRow in d3.js 7

Helper function to isolate each row.

See also

options_form().

5 calls to D3ViewsDataMapping::formRow()
D3ViewsDataMapping::form1DN in modules/d3_views/includes/D3ViewsDataMapping.inc
1-dimensional numeric array of fields / labels.
D3ViewsDataMapping::form2DNAV in modules/d3_views/includes/D3ViewsDataMapping.inc
2-dimensional numeric array of associative array of row values.
D3ViewsDataMapping::formRepeatedRow in modules/d3_views/includes/D3ViewsDataMapping.inc
D3ViewsDataMapping::formRepeatedSubRow in modules/d3_views/includes/D3ViewsDataMapping.inc
D3ViewsDataMapping::formS in modules/d3_views/includes/D3ViewsDataMapping.inc

File

modules/d3_views/includes/D3ViewsDataMapping.inc, line 120

Class

D3ViewsDataMapping

Code

protected function formRow(&$field, $field_info, &$form_state, StdClass $default_values) {
  $field_names = $this->plugin->display->handler
    ->get_field_labels();
  $handlers = $this->plugin->display->handler
    ->get_handlers('field');
  $field['name'] = array(
    '#title' => t('Lib data field'),
    '#markup' => $field_info['label'],
  );
  $field['type'] = array(
    '#title' => t('Variable type'),
    '#markup' => $field_info['type'],
  );
  $field['description'] = array(
    '#title' => 'Description',
    '#markup' => !empty($field_info['description']) ? $field_info['description'] : NULL,
  );
  $field['field'] = array(
    '#title' => t('View field'),
    '#type' => 'select',
    '#options' => array(
      '__none' => '-- No mapping --',
    ) + $field_names,
    '#default_value' => $default_values->field,
    '#ajax' => array(
      'path' => views_ui_build_form_url($form_state),
    ),
  );
  $field['aggregation'] = array(
    '#title' => t('Aggregation'),
    '#type' => 'select',
    '#options' => array(
      '_none' => t('None'),
      'unique' => t('Unique'),
      'count' => t('Count'),
    ),
    '#default_value' => $default_values->aggregation,
  );

  // Run a check on the field type if it's been selected, compare to the
  // field type in the libraries info.
  if ($default_values->field && $default_values->field != '__none') {
    $field['field']['#suffix'] = $this->plugin
      ->checkFieldType($handlers[$default_values->field], $field_info['type']);
  }

  // We can't use aggregation on data that isn't in the main data array.
}