You are here

public function D3ViewsDataMapping::form in d3.js 7

File

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

Class

D3ViewsDataMapping

Code

public function form(&$form, &$form_state) {
  $data_key = $this->library
    ->getDataKey();
  $form['fields'] = array(
    '#type' => 'container',
    '#tree' => TRUE,
  );
  foreach ($this->library
    ->getFields() as $key => $data) {
    if ($key == '_info') {
      continue;
    }
    $element =& $form['fields'][$key];
    $element['#caption'] = t('Data required for settings.!key.', array(
      '!key' => $key,
    ));
    if ($data_key == $key) {
      $element['#caption'] .= t(' This is the main data array that will be used in the visualization.');
      $data['_info']['data_type'] = '2dnav';
    }

    // Set to "2dnav" by default.
    if ($key == '_info' || empty($data['_info']['data_type'])) {
      continue;
    }
    $data_type = strtoupper($data['_info']['data_type']);
    if (method_exists($this, 'form' . $data_type)) {
      $this
        ->{'form' . $data_type}($form, $form_state, $data, $key);
    }
  }
  $this
    ->formRepeated($form, $form_state);
}