public function ChartsBlock::blockForm in Charts 8.4
Same name and namespace in other branches
- 8.3 modules/charts_blocks/src/Plugin/Block/ChartsBlock.php \Drupal\charts_blocks\Plugin\Block\ChartsBlock::blockForm()
- 5.0.x modules/charts_blocks/src/Plugin/Block/ChartsBlock.php \Drupal\charts_blocks\Plugin\Block\ChartsBlock::blockForm()
Overrides BlockPluginTrait::blockForm
File
- modules/
charts_blocks/ src/ Plugin/ Block/ ChartsBlock.php, line 54
Class
- ChartsBlock
- Provides a 'ChartsBlock' block.
Namespace
Drupal\charts_blocks\Plugin\BlockCode
public function blockForm($form, FormStateInterface $form_state) {
parent::blockForm($form, $form_state);
$chart_block_configurations = !empty($this->configuration['chart']) ? $this->configuration['chart'] : [];
if (!empty($this->chartsDefaultSettings)) {
// Get the charts default settings.
$default_options = $this->chartsDefaultSettings;
// Merge the charts default settings with this block's configuration.
$defaults = NestedArray::mergeDeep($default_options, $chart_block_configurations);
}
else {
$defaults = $chart_block_configurations;
}
$form['chart'] = [
'#type' => 'details',
'#title' => $this
->t('Chart configurations'),
'#open' => TRUE,
];
$form['chart']['settings'] = [
'#type' => 'charts_settings',
'#used_in' => 'basic_form',
'#required' => TRUE,
'#series' => TRUE,
'#default_value' => $defaults,
];
return $form;
}