You are here

public function NodeContent::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/NodeContent.php, line 23

Class

NodeContent
Provides a 'node content' tab type.

Namespace

Drupal\quicktabs\Plugin\TabType

Code

public function optionsForm(array $tab) {
  $plugin_id = $this
    ->getPluginDefinition()['id'];
  $form = [];
  $form['nid'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Node'),
    '#description' => $this
      ->t('The node ID of the node.'),
    '#maxlength' => 10,
    '#size' => 20,
    '#default_value' => isset($tab['content'][$plugin_id]['options']['nid']) ? $tab['content'][$plugin_id]['options']['nid'] : '',
  ];
  $display_repository = \Drupal::service('entity_display.repository');
  $view_modes = $display_repository
    ->getViewModes('node');
  $options = [];
  foreach ($view_modes as $view_mode_name => $view_mode) {
    $options[$view_mode_name] = $view_mode['label'];
  }
  $form['view_mode'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('View mode'),
    '#options' => $options,
    '#default_value' => isset($tab['content'][$plugin_id]['options']['view_mode']) ? $tab['content'][$plugin_id]['options']['view_mode'] : 'full',
  ];
  $form['hide_title'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Hide the title of this node'),
    '#default_value' => isset($tab['content'][$plugin_id]['options']['hide_title']) ? $tab['content'][$plugin_id]['options']['hide_title'] : 1,
  ];
  return $form;
}