public function Attachment::buildOptionsForm

Provide the default form for setting options.

Overrides DisplayPluginBase::buildOptionsForm

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/display/Attachment.php, line 143
Definition of Drupal\views\Plugin\views\display\Attachment.

Class

Attachment
The plugin that handles an attachment display.

Namespace

Drupal\views\Plugin\views\display

Code

public function buildOptionsForm(&$form, &$form_state) {

  // It is very important to call the parent function here:
  parent::buildOptionsForm($form, $form_state);
  switch ($form_state['section']) {
    case 'inherit_arguments':
      $form['#title'] .= t('Inherit contextual filters');
      $form['inherit_arguments'] = array(
        '#type' => 'checkbox',
        '#title' => t('Inherit'),
        '#description' => t('Should this display inherit its contextual filter values from the parent display to which it is attached?'),
        '#default_value' => $this
          ->getOption('inherit_arguments'),
      );
      break;
    case 'inherit_exposed_filters':
      $form['#title'] .= t('Inherit exposed filters');
      $form['inherit_exposed_filters'] = array(
        '#type' => 'checkbox',
        '#title' => t('Inherit'),
        '#description' => t('Should this display inherit its exposed filter values from the parent display to which it is attached?'),
        '#default_value' => $this
          ->getOption('inherit_exposed_filters'),
      );
      break;
    case 'inherit_pager':
      $form['#title'] .= t('Inherit pager');
      $form['inherit_pager'] = array(
        '#type' => 'checkbox',
        '#title' => t('Inherit'),
        '#description' => t('Should this display inherit its paging values from the parent display to which it is attached?'),
        '#default_value' => $this
          ->getOption('inherit_pager'),
      );
      break;
    case 'render_pager':
      $form['#title'] .= t('Render pager');
      $form['render_pager'] = array(
        '#type' => 'checkbox',
        '#title' => t('Render'),
        '#description' => t('Should this display render the pager values? This is only meaningful if inheriting a pager.'),
        '#default_value' => $this
          ->getOption('render_pager'),
      );
      break;
    case 'attachment_position':
      $form['#title'] .= t('Position');
      $form['attachment_position'] = array(
        '#type' => 'radios',
        '#description' => t('Attach before or after the parent display?'),
        '#options' => $this
          ->attachmentPositions(),
        '#default_value' => $this
          ->getOption('attachment_position'),
      );
      break;
    case 'displays':
      $form['#title'] .= t('Attach to');
      $displays = array();
      foreach ($this->view->display as $display_id => $display) {
        if (!empty($this->view->displayHandlers[$display_id]) && $this->view->displayHandlers[$display_id]
          ->acceptAttachments()) {
          $displays[$display_id] = $display['display_title'];
        }
      }
      $form['displays'] = array(
        '#type' => 'checkboxes',
        '#description' => t('Select which display or displays this should attach to.'),
        '#options' => $displays,
        '#default_value' => $this
          ->getOption('displays'),
      );
      break;
  }
}