You are here

public function ChartsConfigForm::buildForm in Charts 8.3

Same name in this branch
  1. 8.3 src/Form/ChartsConfigForm.php \Drupal\charts\Form\ChartsConfigForm::buildForm()
  2. 8.3 modules/charts_chartjs/src/Form/ChartsConfigForm.php \Drupal\charts_chartjs\Form\ChartsConfigForm::buildForm()
  3. 8.3 modules/charts_google/src/Form/ChartsConfigForm.php \Drupal\charts_google\Form\ChartsConfigForm::buildForm()
  4. 8.3 modules/charts_billboard/src/Form/ChartsConfigForm.php \Drupal\charts_billboard\Form\ChartsConfigForm::buildForm()
  5. 8.3 modules/charts_c3/src/Form/ChartsConfigForm.php \Drupal\charts_c3\Form\ChartsConfigForm::buildForm()
  6. 8.3 modules/charts_highcharts/src/Form/ChartsConfigForm.php \Drupal\charts_highcharts\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

modules/charts_highcharts/src/Form/ChartsConfigForm.php, line 31

Class

ChartsConfigForm
Charts Config Form.

Namespace

Drupal\charts_highcharts\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('charts_highcharts.settings');
  $form['placeholder'] = [
    '#title' => $this
      ->t('Placeholder'),
    '#type' => 'fieldset',
    '#description' => $this
      ->t('This is a placeholder for Highcharts-specific library options. If you would like to help build this out, please work from <a href="@issue_link">this issue</a>.', [
      '@issue_link' => Url::fromUri('https://www.drupal.org/project/charts/issues/3046981')
        ->toString(),
    ]),
  ];
  $form['legend'] = [
    '#title' => $this
      ->t('Legend Settings'),
    '#type' => 'fieldset',
  ];
  $form['legend']['legend_layout'] = [
    '#title' => $this
      ->t('Legend layout'),
    '#type' => 'select',
    '#options' => [
      'vertical' => t('Vertical'),
      'horizontal' => t('Horizontal'),
    ],
    '#default_value' => $config
      ->get('legend_layout'),
  ];
  $form['legend']['legend_background_color'] = [
    '#title' => $this
      ->t('Legend background color'),
    '#type' => 'textfield',
    '#size' => 10,
    '#maxlength' => 7,
    '#attributes' => [
      'placeholder' => t('transparent'),
    ],
    '#description' => t('Leave blank for a transparent background.'),
    '#default_value' => $config
      ->get('legend_background_color'),
  ];
  $form['legend']['legend_border_width'] = [
    '#title' => $this
      ->t('Legend border width'),
    '#type' => 'select',
    '#options' => [
      0 => t('None'),
      1 => 1,
      2 => 2,
      3 => 3,
      4 => 4,
      5 => 5,
    ],
    '#default_value' => $config
      ->get('legend_border_width'),
  ];
  $form['legend']['legend_shadow'] = [
    '#title' => $this
      ->t('Legend shadow'),
    '#type' => 'select',
    '#options' => [
      'FALSE' => t('Disabled'),
      'TRUE' => t('Enabled'),
    ],
    '#default_value' => $config
      ->get('legend_shadow'),
  ];
  $form['legend']['item_style'] = [
    '#title' => $this
      ->t('Item Style'),
    '#type' => 'fieldset',
  ];
  $form['legend']['item_style']['item_style_color'] = [
    '#title' => $this
      ->t('Item style color'),
    '#type' => 'textfield',
    '#size' => 10,
    '#maxlength' => 7,
    '#attributes' => [
      'placeholder' => '#333333',
    ],
    '#description' => t('Leave blank for a dark gray font.'),
    '#default_value' => $config
      ->get('item_style_color'),
  ];
  $form['legend']['item_style']['text_overflow'] = [
    '#title' => $this
      ->t('Text overflow'),
    '#type' => 'select',
    '#options' => [
      'FALSE' => t('False'),
      'ellipsis' => t('Ellipsis'),
    ],
    '#default_value' => $config
      ->get('text_overflow'),
  ];
  return parent::buildForm($form, $form_state);
}