You are here

protected function TreeStyleTrait::getCommonOptionsForm in Views tree 8.2

Builds common form elements for the options form.

Parameters

array $form: The form definition.

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

2 calls to TreeStyleTrait::getCommonOptionsForm()
Tree::buildOptionsForm in src/Plugin/views/style/Tree.php
Render the given style.
TreeTable::buildOptionsForm in src/Plugin/views/style/TreeTable.php
Render the given style.

File

src/TreeStyleTrait.php, line 31

Class

TreeStyleTrait
Contains common code for list and table tree style displays.

Namespace

Drupal\views_tree

Code

protected function getCommonOptionsForm(array &$form, FormStateInterface $form_state) {
  $fields = [
    '' => $this
      ->t('<None>'),
  ];
  foreach ($this->displayHandler
    ->getHandlers('field') as $field => $handler) {
    $fields[$field] = $handler
      ->adminLabel();
  }
  $form['main_field'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Main field'),
    '#options' => $fields,
    '#default_value' => $this->options['main_field'],
    '#description' => $this
      ->t('Select the field with the unique identifier for each record.'),
    '#required' => TRUE,
  ];
  $form['parent_field'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Parent field'),
    '#options' => $fields,
    '#default_value' => $this->options['parent_field'],
    '#description' => $this
      ->t("Select the field that contains the unique identifier of the record's parent."),
  ];
}