submitOptionsForm example

if ($form_state->getErrors()) {
      $form_state->set('rerender', TRUE);
    }
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $view->getExecutable()->displayHandlers->get($display_id)->submitOptionsForm($form['options']$form_state);

    $view->cacheSet();
  }

}
'#type' => 'checkbox',
      '#title' => $this->t('Bypass access checks'),
      '#description' => $this->t('If enabled, access permissions for rendering the entity are not checked.'),
      '#default_value' => !empty($this->options['bypass_access']),
    ];
  }

  /** * {@inheritdoc} */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    parent::submitOptionsForm($form$form_state);

    // Load the referenced entity and store its config target identifier if     // the target does not contains tokens.     // @todo Use a method to check for tokens in     // https://www.drupal.org/node/2396607.     $options = $form_state->getValue('options');
    if (!str_contains($options['target'], '{{')) {
      if ($entity = $this->entityTypeManager->getStorage($this->entityType)->load($options['target'])) {
        $options['target'] = $entity->getConfigTarget();
      }
      $form_state->setValue('options', $options);
    }


  /** * {@inheritdoc} */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    // Merge plural format options into one string and drop the individual     // option values.     $options = &$form_state->getValue('options');
    $options['format_plural_string'] = implode(PoItem::DELIMITER, $options['format_plural_values']);
    unset($options['format_plural_values']);
    parent::submitOptionsForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function render(ResultRow $values) {
    $value = $this->getValue($values);

    // Check to see if hiding should happen before adding prefix and suffix     // and before rewriting.     if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) {
      
break;

      case 'path':
        $form['path']['#description'] = $this->t('This view will be displayed by visiting this path on your site. It is recommended that the path be something like "path/%/%/feed" or "path/%/%/rss.xml", putting one % in the path for each contextual filter you have defined in the view.');
    }
  }

  /** * {@inheritdoc} */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    parent::submitOptionsForm($form$form_state);
    $section = $form_state->get('section');
    switch ($section) {
      case 'title':
        $this->setOption('sitename_title', $form_state->getValue('sitename_title'));
        break;

      case 'displays':
        $this->setOption($section$form_state->getValue($section));
        break;
    }
  }

  
if (!trim($form_state->getValue('test_option'))) {
          $form_state->setError($form['test_option']$this->t('You cannot have an empty option.'));
        }
        break;
    }
  }

  /** * {@inheritdoc} */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    parent::submitOptionsForm($form$form_state);
    switch ($form_state->get('section')) {
      case 'test_option':
        $this->setOption('test_option', $form_state->getValue('test_option'));
        break;
    }
  }

  /** * {@inheritdoc} */
  public function execute() {
    
/** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $id = $form_state->get('id');
    $handler = $form_state->get('handler');

    // Run it through the handler's submit function.     $handler->submitOptionsForm($form['options']$form_state);
    $item = $handler->options;
    $types = ViewExecutable::getHandlerTypes();

    // For footer/header $handler_type is area but $type is footer/header.     // For all other handle types it's the same.     $handler_type = $type = $form_state->get('type');
    if (!empty($types[$type]['type'])) {
      $handler_type = $types[$type]['type'];
    }

    $override = NULL;
    
if ($menu_type != 'none' && $form_state->isValueEmpty(['menu', 'title'])) {
        $form_state->setError($form['menu']['title']$this->t('Title is required for this menu type.'));
      }
    }
  }

  /** * {@inheritdoc} */
  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;

      


      // Automatically remove '/' and trailing whitespace from path.       $form_state->setValue('path', trim($form_state->getValue('path'), '/ '));
    }
  }

  /** * {@inheritdoc} */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    parent::submitOptionsForm($form$form_state);

    if ($form_state->get('section') == 'path') {
      $this->setOption('path', $form_state->getValue('path'));
    }
  }

  /** * Validates the path of the display. * * @param string $path * The path to validate. * * @return array * A list of error strings. */
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    $option_values = &$form_state->getValue('options');
    if (empty($option_values)) {
      return;
    }

    // Let the plugins make submit modifications if necessary.     $default_id = $option_values['default_argument_type'];
    $plugin = $this->getPlugin('argument_default', $default_id);
    if ($plugin) {
      $options = &$option_values['argument_default'][$default_id];
      $plugin->submitOptionsForm($form['argument_default'][$default_id]$form_state$options);
      // Copy the now submitted options to their final resting place so they get saved.       $option_values['default_argument_options'] = $options;
    }

    // summary plugin     $summary_id = $option_values['summary']['format'];
    $plugin = $this->getPlugin('style', $summary_id);
    if ($plugin) {
      $options = &$option_values['summary']['options'][$summary_id];
      $plugin->submitOptionsForm($form['summary']['options'][$summary_id]$form_state$options);
      // Copy the now submitted options to their final resting place so they get saved.
$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. */
  public function submitTemporaryForm($form, FormStateInterface $form_state) {
    // Run it through the handler's submit function.     $this->submitOptionsForm($form['options']$form_state);
    $item = $this->options;
    $types = ViewExecutable::getHandlerTypes();

    // For footer/header $handler_type is area but $type is footer/header.     // For all other handle types it's the same.     $handler_type = $type = $form_state->get('type');
    if (!empty($types[$type]['type'])) {
      $handler_type = $types[$type]['type'];
    }

    $override = NULL;
    

        break;
    }
  }

  /** * Perform any necessary changes to the form values prior to storage. * * There is no need for this function to actually store the data. */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    parent::submitOptionsForm($form$form_state);
    $section = $form_state->get('section');
    switch ($section) {
      case 'block_description':
      case 'block_category':
      case 'allow':
      case 'block_hide_empty':
        $this->setOption($section$form_state->getValue($section));
        break;
    }
  }

  
'#description' => $this->t('These are the supported authentication providers for this view. When this view is requested, the client will be forced to authenticate with one of the selected providers. Make sure you set the appropriate requirements at the <em>Access</em> section since the Authentication System will fallback to the anonymous user if it fails to authenticate. For example: require Access: Role | Authenticated User.'),
        '#options' => $this->getAuthOptions(),
        '#default_value' => $this->getOption('auth'),
      ];
    }
  }

  /** * {@inheritdoc} */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    parent::submitOptionsForm($form$form_state);

    if ($form_state->get('section') == 'auth') {
      $this->setOption('auth', array_keys(array_filter($form_state->getValue('auth'))));
    }
  }

  /** * {@inheritdoc} */
  public function collectRoutes(RouteCollection $collection) {
    parent::collectRoutes($collection);
    

        break;

      case 'display_title':
        $this->display['display_title'] = $form_state->getValue('display_title');
        $this->setOption('display_description', $form_state->getValue('display_description'));
        break;

      case 'query':
        $plugin = $this->getPlugin('query');
        if ($plugin) {
          $plugin->submitOptionsForm($form['query']['options']$form_state);
          $this->setOption('query', $form_state->getValue($section));
        }
        break;

      case 'link_display':
        $this->setOption('link_url', $form_state->getValue('link_url'));
      case 'title':
      case 'css_class':
      case 'display_comment':
      case 'distinct':
      case 'group_by':
        
'#type' => 'textfield',
          '#description' => $this->t('This is a textfield for test_option.'),
          '#default_value' => $this->options['test_extender_test_option'],
        ];
    }
  }

  /** * {@inheritdoc} */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    parent::submitOptionsForm($form$form_state);
    switch ($form_state->get('section')) {
      case 'test_extender_test_option':
        $this->options['test_extender_test_option'] = $form_state->getValue('test_extender_test_option');
        break;
    }
  }

  /** * {@inheritdoc} */
  public function defaultableSections(&$sections$section = NULL) {
    

    elseif ($was_defaulted === $is_defaulted) {
      // We're not changing which display these form values apply to.       // Run the regular submit handler for this form.     }
    elseif ($was_defaulted && !$is_defaulted) {
      // We were using the default display's values, but we're now overriding       // the default display and saving values specific to this display.       $display = &$this->getExecutable()->displayHandlers->get($display_id);
      // optionsOverride toggles the override of this section.       $display->optionsOverride($form$form_state);
      $display->submitOptionsForm($form$form_state);
    }
    elseif (!$was_defaulted && $is_defaulted) {
      // We used to have an override for this display, but the user now wants       // to go back to the default display.       // Overwrite the default display with the current form values, and make       // the current display use the new default values.       $display = &$this->getExecutable()->displayHandlers->get($display_id);
      // optionsOverride toggles the override of this section.       $display->optionsOverride($form$form_state);
      $display->submitOptionsForm($form$form_state);
    }

    
Home | Imprint | This part of the site doesn't use cookies.