Skip to content
Snippets Groups Projects
Commit 40310bf3 authored by andileco's avatar andileco
Browse files

Make the default settings form Charting Library field match the views options form.

parent 307b271e
No related branches found
No related tags found
No related merge requests found
...@@ -140,7 +140,12 @@ class ChartsConfigForm extends ConfigFormBase { ...@@ -140,7 +140,12 @@ class ChartsConfigForm extends ConfigFormBase {
$charts_info = $this->charts_info(); $charts_info = $this->charts_info();
$library_options = []; $library_options = [];
foreach ($charts_info as $library_name => $library_info) { foreach ($charts_info as $library_name => $library_info) {
$library_options[$library_name] = $library_info['label']; if (\Drupal::moduleHandler()->moduleExists($charts_info[$library_name]['module'])) {
$library_options[$library_name] = $library_info['label'];
}
}
if (count($library_options) == 0) {
drupal_set_message(t('There are no enabled charting libraries. Please enable a Charts sub-module.'));
} }
$form['library'] = [ $form['library'] = [
'#title' => $this->t('Charting library'), '#title' => $this->t('Charting library'),
...@@ -148,7 +153,7 @@ class ChartsConfigForm extends ConfigFormBase { ...@@ -148,7 +153,7 @@ class ChartsConfigForm extends ConfigFormBase {
'#options' => $library_options, '#options' => $library_options,
'#default_value' => $options['library'], '#default_value' => $options['library'],
'#required' => TRUE, '#required' => TRUE,
'#access' => count($library_options) > 1, '#access' => count($library_options) > 0,
'#attributes' => ['class' => ['chart-library-select']], '#attributes' => ['class' => ['chart-library-select']],
'#weight' => -15, '#weight' => -15,
'#parents' => array_merge($parents, ['library']), '#parents' => array_merge($parents, ['library']),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment