You are here

public function ViewsRowsWrapper::buildOptionsForm in Views Rows Wrapper 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/views/style/ViewsRowsWrapper.php \Drupal\views_rows_wrapper\Plugin\views\style\ViewsRowsWrapper::buildOptionsForm()

Provide a form to edit options for this plugin.

Overrides StylePluginBase::buildOptionsForm

File

src/Plugin/views/style/ViewsRowsWrapper.php, line 61

Class

ViewsRowsWrapper
A Views style that renders markup for Bootstrap tabs.

Namespace

Drupal\views_rows_wrapper\Plugin\views\style

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['use_wrapper'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use this row wrapper'),
    '#default_value' => $this->options['use_wrapper'],
    '#description' => $this
      ->t('Check if you want to use this plugin.'),
  ];
  $form['use_additional_wrapper'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use the additional wrapper'),
    '#default_value' => $this->options['use_additional_wrapper'],
    '#description' => $this
      ->t('Check if you want to use the additional (external) wrapper provided by this module.'),
    '#states' => [
      'visible' => [
        ':input[name="style_options[use_wrapper]"]' => [
          'checked' => TRUE,
        ],
      ],
      'enabled' => [
        ':input[name="style_options[use_wrapper]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['element_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Element type'),
    '#options' => $this->options['element_types'],
    '#default_value' => $this->options['element_type'],
    '#description' => $this
      ->t('Select element type.'),
  ];
  $form['attribute_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Attribute type'),
    '#options' => $this->options['attribute_types'],
    '#default_value' => $this->options['attribute_type'],
    '#description' => $this
      ->t('Select attribute type.'),
  ];
  $form['attribute_name'] = [
    '#title' => $this
      ->t('Class/ID attribute name(s)'),
    '#type' => 'textfield',
    '#default_value' => $this->options['attribute_name'],
  ];
  $form['original_row_class_name'] = [
    '#title' => $this
      ->t('Original row class name(s)'),
    '#type' => 'textfield',
    '#default_value' => $this->options['original_row_class_name'],
  ];
  $form['rows_number'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Number of rows to wrap'),
    '#min' => 1,
    '#default_value' => $this->options['rows_number'],
    '#description' => $this
      ->t('Choose the number of rows to be wrapped by selected element.'),
  ];
  $form['wrap_method'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Wrap method'),
    '#default_value' => $this->options['wrap_method'],
    '#options' => [
      0 => $this
        ->t('Apply to all items'),
      1 => $this
        ->t('Wrap once (first rows only)'),
    ],
    '#description' => $this
      ->t('Select the method of how you want to wrap your view results.'),
  ];
  $form['default_rows'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add views row classes'),
    '#default_value' => $this->options['default_rows'],
    '#description' => $this
      ->t('Add the default row classes like views-row-1 to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.'),
  ];
  $form['strip_rows'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add striping (odd/even), first/last row classes'),
    '#default_value' => $this->options['strip_rows'],
    '#description' => $this
      ->t('Add css classes to the first and last line, as well as odd/even classes for striping.'),
  ];
}