--- a/src/Element/BaseSettings.php +++ b/src/Element/BaseSettings.php @@ -1272,7 +1272,10 @@ class BaseSettings extends FormElementBase { $id_prefix = implode('-', $parents); $element_state = static::getElementState($parents, $form_state); $state_color_indexes_key = $id_prefix . '__default_display_color_indexes'; - $options_display_colors = $options['display']['colors']; + if (!isset($options['display']['colors']) || !is_array($options['display']['colors'])) { + $options['display']['colors'] = []; + } + $options_display_colors = $options['display']['colors']; if (!$element_state) { $element_state = $options; $options_display_colors_indexes = !empty($options_display_colors) ? array_keys($options_display_colors) : []; @@ -1353,7 +1356,7 @@ class BaseSettings extends FormElementBase { ], '#operation' => 'add', '#element_state_indexes_key' => $state_color_indexes_key, - '#array_slicing_args' => ['offset' => 0, 'length' => -4], + '#array_slicing_args' => ['offset' => 0, 'length' => -5], ]; $element['display']['color_changer'] = [ --- a/src/Form/ChartsConfigForm.php +++ b/src/Form/ChartsConfigForm.php @@ -200,9 +200,12 @@ class ChartsConfigForm extends ConfigFormBase { } // Process the default colors to remove unneeded data. - foreach ($settings['display']['colors'] as $color_index => $color_item) { - $settings['display']['colors'][$color_index] = $color_item['color']; + if (!is_array($settings['display']['colors'] ?? NULL)) { + $settings['display']['colors'] = []; } + foreach ($settings['display']['colors'] as $color_index => $color_item) { + $settings['display']['colors'][$color_index] = $color_item['color']; + } // Save the main settings. $config = $this->config('charts.settings');