function ViewEditForm::buildOptionForm

Same name in other branches
  1. 9 core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::buildOptionForm()
  2. 8.9.x core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::buildOptionForm()
  3. 11.x core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::buildOptionForm()

Build a renderable array representing one option on the edit form.

This function might be more logical as a method on an object, if a suitable object emerges out of refactoring.

1 call to ViewEditForm::buildOptionForm()
ViewEditForm::getDisplayDetails in core/modules/views_ui/src/ViewEditForm.php
Helper function to get the display details section of the edit UI.

File

core/modules/views_ui/src/ViewEditForm.php, line 964

Class

ViewEditForm
Form controller for the Views edit form.

Namespace

Drupal\views_ui

Code

public function buildOptionForm(ViewUI $view, $id, $option, $display) {
    $option_build = [];
    $option_build['#theme'] = 'views_ui_display_tab_setting';
    $option_build['#description'] = $option['title'];
    $option_build['#link'] = $view->getExecutable()->displayHandlers
        ->get($display['id'])
        ->optionLink($option['value'], $id, '', empty($option['desc']) ? '' : $option['desc']);
    $option_build['#links'] = [];
    if (!empty($option['links']) && is_array($option['links'])) {
        foreach ($option['links'] as $link_id => $link_value) {
            $option_build['#settings_links'][] = $view->getExecutable()->displayHandlers
                ->get($display['id'])
                ->optionLink($option['setting'], $link_id, 'views-button-configure', $link_value);
        }
    }
    if (!empty($view->getExecutable()->displayHandlers
        ->get($display['id'])->options['defaults'][$id])) {
        $display_id = 'default';
        $option_build['#defaulted'] = TRUE;
    }
    else {
        $display_id = $display['id'];
        if (!$view->getExecutable()->displayHandlers
            ->get($display['id'])
            ->isDefaultDisplay()) {
            if ($view->getExecutable()->displayHandlers
                ->get($display['id'])
                ->defaultableSections($id)) {
                $option_build['#overridden'] = TRUE;
            }
        }
    }
    $option_build['#attributes']['class'][] = Html::cleanCssIdentifier($display_id . '-' . $id);
    return $option_build;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.