You are here

public function Block::buildOptionsForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/display/Block.php \Drupal\views\Plugin\views\display\Block::buildOptionsForm()

Provide the default form for setting options.

Overrides DisplayPluginBase::buildOptionsForm

File

core/modules/views/src/Plugin/views/display/Block.php, line 182
Contains \Drupal\views\Plugin\views\display\Block.

Class

Block
The plugin that handles a block.

Namespace

Drupal\views\Plugin\views\display

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  switch ($form_state
    ->get('section')) {
    case 'block_description':
      $form['#title'] .= $this
        ->t('Block admin description');
      $form['block_description'] = array(
        '#type' => 'textfield',
        '#description' => $this
          ->t('This will appear as the name of this block in administer >> structure >> blocks.'),
        '#default_value' => $this
          ->getOption('block_description'),
      );
      break;
    case 'block_category':
      $form['#title'] .= $this
        ->t('Block category');
      $form['block_category'] = array(
        '#type' => 'textfield',
        '#autocomplete_route_name' => 'block.category_autocomplete',
        '#description' => $this
          ->t('The category this block will appear under on the <a href=":href">blocks placement page</a>.', array(
          ':href' => \Drupal::url('block.admin_display'),
        )),
        '#default_value' => $this
          ->getOption('block_category'),
      );
      break;
    case 'block_hide_empty':
      $form['#title'] .= $this
        ->t('Block empty settings');
      $form['block_hide_empty'] = array(
        '#title' => $this
          ->t('Hide block if no result/empty text'),
        '#type' => 'checkbox',
        '#description' => $this
          ->t('Hide the block if there is no result and no empty text and no header/footer which is shown on empty result'),
        '#default_value' => $this
          ->getOption('block_hide_empty'),
      );
      break;
    case 'exposed_form_options':
      $this->view
        ->initHandlers();
      if (!$this
        ->usesExposed() && parent::usesExposed()) {
        $form['exposed_form_options']['warning'] = array(
          '#weight' => -10,
          '#markup' => '<div class="messages messages--warning">' . $this
            ->t('Exposed filters in block displays require "Use AJAX" to be set to work correctly.') . '</div>',
        );
      }
      break;
    case 'allow':
      $form['#title'] .= $this
        ->t('Allow settings in the block configuration');
      $options = array(
        'items_per_page' => $this
          ->t('Items per page'),
      );
      $allow = array_filter($this
        ->getOption('allow'));
      $form['allow'] = array(
        '#type' => 'checkboxes',
        '#default_value' => $allow,
        '#options' => $options,
      );
      break;
  }
}