views_ui_build_form_url example

'#default_value' => $this->options['click_sort_column'],
        '#description' => $this->t('Used by Style: Table to determine the actual column to click sort the field on. The default is usually fine.'),
      ];
    }

    $form['type'] = [
      '#type' => 'select',
      '#title' => $this->t('Formatter'),
      '#options' => $formatters,
      '#default_value' => $this->options['type'],
      '#ajax' => [
        'url' => views_ui_build_form_url($form_state),
      ],
      '#submit' => [[$this, 'submitTemporaryForm']],
      '#executes_submit_callback' => TRUE,
    ];

    $form['field_api_classes'] = [
      '#title' => $this->t('Use field template'),
      '#type' => 'checkbox',
      '#default_value' => $this->options['field_api_classes'],
      '#description' => $this->t('If checked, field api classes will be added by field templates. This is not recommended unless your CSS depends upon these classes. If not checked, template will not be used.'),
      '#fieldset' => 'style_settings',
      
// Sometimes we need to re-generate the form for multi-step type operations.     if (!empty($view->stack)) {
      $stack = $view->stack;
      $top = array_shift($stack);

      // Build the new form state for the next form in the stack.       $reflection = new \ReflectionClass($view::$forms[$top[1]]);
      $form_state = $reflection->newInstanceArgs(array_slice($top, 3, 2))->getFormState($view$top[2]$form_state->get('ajax'));
      $form_class = get_class($form_state->getFormObject());

      $form_state->setUserInput([]);
      $form_url = views_ui_build_form_url($form_state);
      if (!$form_state->get('ajax')) {
        return new RedirectResponse($form_url->setAbsolute()->toString());
      }
      $form_state->set('url', $form_url);
      $response = $this->ajaxFormWrapper($form_class$form_state);
    }
    elseif (!$form_state->get('ajax')) {
      // if nothing on the stack, non-js forms just go back to the main view editor.       $display_id = $form_state->get('display_id');
      return new RedirectResponse(Url::fromRoute('entity.view.edit_display_form', ['view' => $view->id(), 'display_id' => $display_id]['absolute' => TRUE])->toString());
    }
    
Home | Imprint | This part of the site doesn't use cookies.