You are here

public function TableSummarized::buildOptionsForm in Views Summarize 1.1.x

Render the given style.

Overrides Table::buildOptionsForm

File

src/Plugin/views/style/TableSummarized.php, line 29

Class

TableSummarized
Style plugin to render summarized data as a row in a table.

Namespace

Drupal\views_summarize\Plugin\views\style

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);

  // This is for themeing the form for the Views Summarized table Settings.
  $form['#theme'] = 'views_summarize_style_plugin_summarized_table';
  $options = $this
    ->getHandlers();
  $columns = $this
    ->sanitizeColumns($this->options['columns']);
  foreach (array_keys($columns) as $field) {
    $safe = str_replace([
      '][',
      '_',
      ' ',
    ], '-', $field);
    $id = 'edit-style-options-columns-' . $safe;
    $form['info'][$field]['summarize'] = [
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => !empty($this->options['info'][$field]['summarize']) ? $this->options['info'][$field]['summarize'] : 'none',
      '#dependency' => [
        $id => [
          $field,
        ],
      ],
    ];
  }
  $form['summary_only'] = [
    '#title' => t('Display the summary row only'),
    '#description' => t('If checked only the summary row will be displayed,'),
    '#type' => 'checkbox',
    '#default_value' => !empty($this->options['summary_only']),
  ];
}