function views_ui_build_form_url

Same name in other branches
  1. 9 core/modules/views_ui/admin.inc \views_ui_build_form_url()
  2. 10 core/modules/views_ui/admin.inc \views_ui_build_form_url()
  3. 11.x core/modules/views_ui/admin.inc \views_ui_build_form_url()

Create the menu path for one of our standard AJAX forms based upon known information about the form.

Return value

\Drupal\Core\Url The URL object pointing to the form URL.

2 calls to views_ui_build_form_url()
EntityField::buildOptionsForm in core/modules/views/src/Plugin/views/field/EntityField.php
Default options form that provides the label widget that all fields should have.
ViewsFormBase::getForm in core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
Creates a new instance of this form.

File

core/modules/views_ui/admin.inc, line 278

Code

function views_ui_build_form_url(FormStateInterface $form_state) {
    $ajax = !$form_state->get('ajax') ? 'nojs' : 'ajax';
    $name = $form_state->get('view')
        ->id();
    $form_key = $form_state->get('form_key');
    $display_id = $form_state->get('display_id');
    $form_key = str_replace('-', '_', $form_key);
    $route_name = "views_ui.form_{$form_key}";
    $route_parameters = [
        'js' => $ajax,
        'view' => $name,
        'display_id' => $display_id,
    ];
    $url = Url::fromRoute($route_name, $route_parameters);
    if ($type = $form_state->get('type')) {
        $url->setRouteParameter('type', $type);
    }
    if ($id = $form_state->get('id')) {
        $url->setRouteParameter('id', $id);
    }
    return $url;
}

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