function d3_views_plugin_style_d3::options_form in d3.js 7
Options form for the given style.
Overrides views_plugin_style::options_form
File
- modules/
d3_views/ views/ plugins/ d3_views_plugin_style_d3.inc, line 72 - Contains the d3 style plugin.
Class
- d3_views_plugin_style_d3
- Style plugin to render a d3 visualization
Code
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// We temporarily disable grouping on all libraries.
// @TODO In future releases there should be an option to group
// if the visualization's data requires it.
$form['grouping']['#access'] = FALSE;
$handlers = $this->display->handler
->get_handlers('field');
// Reload the library from $form_state if called by ajax.
$library = $this
->getLibrary($form_state);
// Reset the library controller.
$this->controller
->setLibrary($library);
$form['library'] = array(
'#title' => 'Library',
'#description' => t('Select which d3 library you would like to use with this view. Note: For instructions on how to incorporate your custom library with views, see the README.txt.'),
'#type' => 'select',
'#options' => $this
->getLibraryOptions(),
'#default_value' => $this->controller
->machineName(),
'#ajax' => array(
'path' => views_ui_build_form_url($form_state),
),
);
$this->controller->mapping
->form($form, $form_state);
// Additional settings.
$form['settings'] = array(
'#type' => 'container',
'#tree' => TRUE,
);
// Can eventually separate these out into different functions.
foreach ($this->controller
->getSettings() as $key => $data) {
$form_element = !empty($data['_info']['form_element']) ? $data['_info']['form_element'] : array();
$form['settings'][$key] = $form_element + array(
'#type' => 'textfield',
'#default_value' => NULL,
'#title' => '',
'#description' => '',
);
if (!empty($this->options['settings'][$key])) {
$form['settings'][$key]['#default_value'] = $this->options['settings'][$key];
}
}
$form['show_table'] = array(
'#title' => 'Show table',
'#type' => 'checkbox',
'#default_value' => $this->options['show_table'],
);
if (empty($handlers)) {
$form['error_markup'] = array(
'#markup' => '<div class="error messages">' . t('You need at least one field before you can configure your table settings') . '</div>',
);
return;
}
// Note: views UI registers this theme handler on our behalf. Your module
// will have to register your theme handlers if you do stuff like this.
$form['#theme'] = 'views_ui_style_d3_options_form';
}