function charts_default_settings_form in Charts 8
Same name and namespace in other branches
- 7.2 includes/charts.pages.inc \charts_default_settings_form()
Menu callback; Configure the site-wide defaults for charts.
_state Standard parameters for a form.
Parameters
$form:
Return value
mixed
File
- includes/
charts.pages.inc, line 569 - Menu callbacks for Charts module.
Code
function charts_default_settings_form($form, $form_state) {
$defaults = \Drupal::state()
->get('charts_default_settings', array());
$defaults += charts_default_settings();
$field_options = array();
$parents = array(
'charts_default_settings',
);
// Add help.
$form['help'] = array(
'#type' => 'markup',
'#markup' => '<p>' . t('The settings on this page are used to set <strong>default</strong> settings. They do not affect existing charts. To make a new chart, <a href="!views">create a new view</a> and select the display format of "Chart".', array(
'!views' => url('admin/structure/views/add'),
)) . '</p>',
'#weight' => -100,
);
// Reuse the global settings form for defaults, but remove JS classes.
$form = charts_settings_form($form, $defaults, $field_options, $parents);
$form['xaxis']['#attributes']['class'] = array();
$form['yaxis']['#attributes']['class'] = array();
$form['display']['colors']['#prefix'] = NULL;
$form['display']['colors']['#suffix'] = NULL;
// Put settings into vertical tabs.
$form['display']['#group'] = 'defaults';
$form['xaxis']['#group'] = 'defaults';
$form['yaxis']['#group'] = 'defaults';
$form['defaults'] = array(
'#type' => 'vertical_tabs',
);
// Add submit buttons and normal saving behavior.
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save defaults'),
);
return $form;
}