addFormToStack example


  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    parent::submitOptionsForm($form$form_state);

    switch ($form_state->get('section')) {
      case 'menu':
        $menu = $form_state->getValue('menu');
        [$menu['menu_name']$menu['parent']] = explode(':', $menu['parent'], 2);
        $this->setOption('menu', $menu);
        // send ajax form to options page if we use it.         if ($form_state->getValue(['menu', 'type']) == 'default tab') {
          $form_state->get('view')->addFormToStack('display', $this->display['id'], 'tab_options');
        }
        break;

      case 'tab_options':
        $this->setOption('tab_options', $form_state->getValue('tab_options'));
        break;

      case 'use_admin_theme':
        if ($form_state->getValue('use_admin_theme')) {
          $this->setOption('use_admin_theme', $form_state->getValue('use_admin_theme'));
        }
        
        $key = $type;
        // Footer,header and empty text have a different internal handler type(area).         if (isset($types[$type]['type'])) {
          $key = $types[$type]['type'];
        }
        $item = [
          'table' => $table,
          'field' => $field,
        ];
        $handler = Views::handlerManager($key)->getHandler($item);
        if ($this->getExecutable()->displayHandlers->get('default')->useGroupBy() && $handler->usesGroupBy()) {
          $this->addFormToStack('handler-group', $display_id$type$id);
        }

        // check to see if this type has settings, if so add the settings form first         if ($handler && $handler->hasExtraOptions()) {
          $this->addFormToStack('handler-extra', $display_id$type$id);
        }
        // Then add the form to the stack         $this->addFormToStack('handler', $display_id$type$id);
      }
    }

    
// If necessary, set new defaults:     if ($item['is_grouped']) {
      $this->buildGroupOptions();
    }

    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $type = $form_state->get('type');
    $id = $form_state->get('id');
    $view->getExecutable()->setHandler($display_id$type$id$item);

    $view->addFormToStack($form_state->get('form_key')$display_id$type$id, TRUE, TRUE);

    $view->cacheSet();
    $form_state->set('rerender', TRUE);
    $form_state->setRebuild();
    $form_state->get('force_build_group_options', TRUE);
  }

  /** * Shortcut to display the expose/hide button. */
  public function showExposeButton(&$form, FormStateInterface $form_state) {
    
// If necessary, set new defaults:     if ($item['exposed']) {
      $this->defaultExposeOptions();
    }

    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $type = $form_state->get('type');
    $id = $form_state->get('id');
    $view->getExecutable()->setHandler($display_id$type$id$item);

    $view->addFormToStack($form_state->get('form_key')$display_id$type$id, TRUE, TRUE);

    $view->cacheSet();
    $form_state->set('rerender', TRUE);
    $form_state->setRebuild();
    $form_state->set('force_expose_options', TRUE);
  }

  /** * Submits a temporary form. * * A submit handler that is used for storing temporary items when using * multi-step changes, such as ajax requests. */

      }
      // Update our cache with values so that cancel still works the way       // people expect.       $view->form_cache = [
        'key' => 'rearrange-filter',
        'groups' => $groups,
        'handlers' => $new_fields,
      ];

      // Return to this form except on actual Update.       $view->addFormToStack('rearrange-filter', $form_state->get('display_id'), 'filter');
    }
    else {
      // The actual update button was clicked. Remove the empty groups, and       // renumber them sequentially.       ksort($remember_groups);
      $groups['groups'] = static::arrayKeyPlus(array_values(array_intersect_key($groups['groups']$remember_groups)));
      // Change the 'group' key on each field to match. Here, $mapping is an       // array whose keys are the old group numbers and whose values are the new       // (sequentially numbered) ones.       $mapping = array_flip(static::arrayKeyPlus(array_keys($remember_groups)));
      foreach ($new_fields as &$new_field) {
        
/** @var \Drupal\views\Plugin\views\ViewsPluginInterface $plugin */
          $plugin = Views::pluginManager($plugin_type)->createInstance($type);
          if ($plugin) {
            $plugin->init($this->view, $this$plugin_options['options']);
            $plugin_options = [
              'type' => $type,
              'options' => $plugin->options,
            ];
            $plugin->filterByDefinedOptions($plugin_options['options']);
            $this->setOption($plugin_type$plugin_options);
            if ($plugin->usesOptions()) {
              $form_state->get('view')->addFormToStack('display', $this->display['id']$plugin_type . '_options');
            }
          }
        }
        break;

      case 'access_options':
      case 'cache_options':
      case 'exposed_form_options':
      case 'pager_options':
      case 'row_options':
      case 'style_options':
        
Home | Imprint | This part of the site doesn't use cookies.