public function ViewContent::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/ ViewContent.php, line 27
Class
- ViewContent
- Provides a 'view content' tab type.
Namespace
Drupal\quicktabs\Plugin\TabTypeCode
public function optionsForm(array $tab) {
$plugin_id = $this
->getPluginDefinition()['id'];
$views = $this
->getViews();
$views_keys = array_keys($views);
$selected_view = isset($tab['content'][$plugin_id]['options']['vid']) ? $tab['content'][$plugin_id]['options']['vid'] : (isset($views_keys[0]) ? $views_keys[0] : '');
$form = [];
$form['vid'] = [
'#type' => 'select',
'#options' => $views,
'#default_value' => $selected_view,
'#title' => $this
->t('Select a view'),
'#ajax' => [
'callback' => [
static::class,
'viewsDisplaysAjaxCallback',
],
'event' => 'change',
'progress' => [
'type' => 'throbber',
'message' => 'Please wait...',
],
'effect' => 'fade',
],
];
$form['display'] = [
'#type' => 'select',
'#title' => 'display',
'#options' => ViewContent::getViewDisplays($selected_view),
'#default_value' => isset($tab['content'][$plugin_id]['options']['display']) ? $tab['content'][$plugin_id]['options']['display'] : '',
'#prefix' => '<div id="view-display-dropdown-' . $tab['delta'] . '">',
'#suffix' => '</div>',
];
$form['args'] = [
'#type' => 'textfield',
'#title' => 'arguments',
'#size' => '40',
'#required' => FALSE,
'#default_value' => isset($tab['content'][$plugin_id]['options']['args']) ? $tab['content'][$plugin_id]['options']['args'] : '',
'#description' => $this
->t('Additional arguments to send to the view as if they were part of the URL in the form of arg1/arg2/arg3. You may use %1, %2, ..., %N to grab arguments from the URL.'),
];
return $form;
}