You are here

public function BlockContent::optionsForm in Quick Tabs 8.3

Return form elements used on the edit/add from.

Parameters

array $tab: The array tab for display.

Return value

array The options used for displaying tabs.

Overrides TabTypeBase::optionsForm

File

src/Plugin/TabType/BlockContent.php, line 26

Class

BlockContent
Provides a 'block content' tab type.

Namespace

Drupal\quicktabs\Plugin\TabType

Code

public function optionsForm(array $tab) {
  $plugin_id = $this
    ->getPluginDefinition()['id'];
  $form = [];
  $form['bid'] = [
    '#type' => 'select',
    '#options' => $this
      ->getBlockOptions(),
    '#default_value' => isset($tab['content'][$plugin_id]['options']['bid']) ? $tab['content'][$plugin_id]['options']['bid'] : '',
    '#title' => $this
      ->t('Select a block'),
    '#ajax' => [
      'callback' => [
        $this,
        'blockTitleAjaxCallback',
      ],
      'event' => 'change',
      'progress' => [
        'type' => 'throbber',
        'message' => 'Please wait...',
      ],
      'effect' => 'fade',
    ],
  ];
  $form['block_title'] = [
    '#type' => 'textfield',
    '#default_value' => isset($tab['content'][$plugin_id]['options']['block_title']) ? $tab['content'][$plugin_id]['options']['block_title'] : '',
    '#title' => $this
      ->t('Block Title'),
    '#prefix' => '<div id="block-title-textfield-' . $tab['delta'] . '">',
    '#suffix' => '</div>',
  ];
  $form['display_title'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display block title'),
    '#default_value' => isset($tab['content'][$plugin_id]['options']['display_title']) ? $tab['content'][$plugin_id]['options']['display_title'] : 0,
  ];
  return $form;
}