You are here

public function ChartsConfigForm::buildForm in Charts 8.4

Same name and namespace in other branches
  1. 8 src/Form/ChartsConfigForm.php \Drupal\charts\Form\ChartsConfigForm::buildForm()
  2. 8.3 src/Form/ChartsConfigForm.php \Drupal\charts\Form\ChartsConfigForm::buildForm()
  3. 5.0.x src/Form/ChartsConfigForm.php \Drupal\charts\Form\ChartsConfigForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/ChartsConfigForm.php, line 71

Class

ChartsConfigForm
Charts Config Form.

Namespace

Drupal\charts\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $default_config = $this->config
    ->get('charts_default_settings') ?: [];
  $form['help'] = [
    '#type' => 'html_tag',
    '#tag' => 'p',
    '#value' => $this
      ->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, create a new view and select the display format of
        "Chart." Or use a Charts Block and add your own data inside that block.
        You can also attach a Chart field to your content (or other entity)
        type and add your data within the Chart field.'),
  ];
  $form['settings'] = [
    '#type' => 'charts_settings',
    '#used_in' => 'config_form',
    '#required' => TRUE,
    '#default_value' => $default_config,
  ];
  return parent::buildForm($form, $form_state);
}