You are here

public function VboExportBase::buildPreConfigurationForm in VBO export 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/Action/VboExportBase.php \Drupal\vbo_export\Plugin\Action\VboExportBase::buildPreConfigurationForm()
1 call to VboExportBase::buildPreConfigurationForm()
VboExportCsv::buildPreConfigurationForm in src/Plugin/Action/VboExportCsv.php
Add csv separator setting to preliminary config.
1 method overrides VboExportBase::buildPreConfigurationForm()
VboExportCsv::buildPreConfigurationForm in src/Plugin/Action/VboExportCsv.php
Add csv separator setting to preliminary config.

File

src/Plugin/Action/VboExportBase.php, line 75

Class

VboExportBase
Base class for export actions.

Namespace

Drupal\vbo_export\Plugin\Action

Code

public function buildPreConfigurationForm(array $form, array $values, FormStateInterface $form_state) {
  $form['strip_tags'] = [
    '#title' => $this
      ->t('Strip HTML tags'),
    '#type' => 'checkbox',
    '#default_value' => isset($values['strip_tags']) ? $values['strip_tags'] : FALSE,
  ];
  $form['field_override'] = [
    '#title' => $this
      ->t('Override the fields configuration'),
    '#type' => 'checkbox',
    '#default_value' => isset($values['field_override']) ? $values['field_override'] : FALSE,
  ];
  if ($this->view instanceof ViewExecutable && !empty($this->view->field)) {
    $form['field_config'] = [
      '#type' => 'table',
      '#caption' => $this
        ->t('Select the fields you want to include in the exportable. <strong>The following options only applies if the "Override the fields configuration" option is checked.</strong>'),
      '#header' => [
        $this
          ->t('Field name'),
        $this
          ->t('Active'),
        $this
          ->t('Label'),
      ],
    ];
    $functional_fields = [
      'views_bulk_operations_bulk_form',
      'entity_operations',
    ];
    foreach ($this->view->field as $field_id => $field) {
      if (in_array($field_id, $functional_fields)) {
        continue;
      }
      $form['field_config'][$field_id] = [
        'name' => [
          '#markup' => $field_id,
        ],
        'active' => [
          '#type' => 'checkbox',
          '#title' => $this
            ->t('Active'),
          '#title_display' => 'invisible',
          '#default_value' => isset($values['field_config'][$field_id]['active']) ? $values['field_config'][$field_id]['active'] : FALSE,
        ],
        'label' => [
          '#type' => 'textfield',
          '#title' => $this
            ->t('Label'),
          '#title_display' => 'invisible',
          '#default_value' => isset($values['field_config'][$field_id]['label']) ? $values['field_config'][$field_id]['label'] : '',
        ],
      ];
    }
  }
  return $form;
}