You are here

public function LocalTasksBlock::blockForm in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Menu/Plugin/Block/LocalTasksBlock.php \Drupal\Core\Menu\Plugin\Block\LocalTasksBlock::blockForm()

Returns the configuration form elements specific to this block plugin.

Blocks that need to add form elements to the normal block configuration form should implement this method.

Parameters

array $form: The form definition array for the block configuration form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array $form The renderable form array representing the entire configuration form.

Overrides BlockBase::blockForm

File

core/lib/Drupal/Core/Menu/Plugin/Block/LocalTasksBlock.php, line 127
Contains \Drupal\Core\Menu\Plugin\Block\LocalTasksBlock.

Class

LocalTasksBlock
Provides a "Tabs" block to display the local tasks.

Namespace

Drupal\Core\Menu\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $config = $this->configuration;
  $defaults = $this
    ->defaultConfiguration();
  $form['levels'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Shown tabs'),
    '#description' => $this
      ->t('Select tabs being shown in the block'),
    // Open if not set to defaults.
    '#open' => $defaults['primary'] !== $config['primary'] || $defaults['secondary'] !== $config['secondary'],
  ];
  $form['levels']['primary'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show primary tabs'),
    '#default_value' => $config['primary'],
  ];
  $form['levels']['secondary'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show secondary tabs'),
    '#default_value' => $config['secondary'],
  ];
  return $form;
}