You are here

public function UIkitViewAccordion::buildOptionsForm in UIkit Components 8.3

Same name and namespace in other branches
  1. 8.2 uikit_views/src/Plugin/views/style/UIkitViewAccordion.php \Drupal\uikit_views\Plugin\views\style\UIkitViewAccordion::buildOptionsForm()

Provide a form to edit options for this plugin.

Overrides StylePluginBase::buildOptionsForm

File

uikit_views/src/Plugin/views/style/UIkitViewAccordion.php, line 58

Class

UIkitViewAccordion
Style plugin to render each item in a UIkit Accordion component.

Namespace

Drupal\uikit_views\Plugin\views\style

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  if (isset($form['grouping'])) {
    unset($form['grouping']);
    $form['title_field'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Title field'),
      '#options' => $this->displayHandler
        ->getFieldLabels(TRUE),
      '#required' => TRUE,
      '#default_value' => $this->options['title_field'],
      '#description' => $this
        ->t('Select the field to use as the accordian title to create a toggle for the accordion items.'),
    ];
    $form['accordion_options'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Accordion options'),
      '#open' => TRUE,
    ];
    $form['targets'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('CSS selector of the element(s) to toggle.'),
      '#default_value' => $this->options['targets'],
      '#fieldset' => 'accordion_options',
    ];
    $form['active'] = [
      '#type' => 'number',
      '#title' => $this
        ->t('Index of the element to open initially.'),
      '#default_value' => $this->options['active'],
      '#fieldset' => 'accordion_options',
    ];
    $form['collapsible'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Allow all items to be closed.'),
      '#default_value' => $this->options['collapsible'],
      '#fieldset' => 'accordion_options',
    ];
    $form['multiple'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Allow multiple open items.'),
      '#default_value' => $this->options['multiple'],
      '#fieldset' => 'accordion_options',
    ];
    $form['animation'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Reveal item directly (unchecked) or with a transition (checked).'),
      '#default_value' => $this->options['animation'],
      '#fieldset' => 'accordion_options',
    ];
    $form['transition'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Transition effect'),
      '#default_value' => $this->options['transition'],
      '#options' => array(
        'linear' => 'linear',
        'ease' => 'ease',
        'ease-in' => 'ease-in',
        'ease-in-out' => 'ease-in-out',
        'ease-out' => 'ease-out',
        'step-start' => 'step-start',
        'step-end' => 'step-end',
      ),
      '#fieldset' => 'accordion_options',
      '#required' => TRUE,
    ];
    $form['duration'] = [
      '#type' => 'number',
      '#title' => $this
        ->t('Animation duration in milliseconds.'),
      '#default_value' => $this->options['duration'],
      '#fieldset' => 'accordion_options',
      '#required' => TRUE,
    ];
  }
}