You are here

public function ArgumentPluginBase::submitOptionsForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php \Drupal\views\Plugin\views\argument\ArgumentPluginBase::submitOptionsForm()

Handle any special handling on the validate form.

Overrides PluginBase::submitOptionsForm

File

core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php, line 436
Contains \Drupal\views\Plugin\views\argument\ArgumentPluginBase.

Class

ArgumentPluginBase
Base class for argument (contextual filter) handler plugins.

Namespace

Drupal\views\Plugin\views\argument

Code

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.
    $option_values['summary_options'] = $options;
  }

  // If the 'Specify validation criteria' checkbox is not checked, reset the
  // validation options.
  if (empty($option_values['specify_validation'])) {
    $option_values['validate']['type'] = 'none';

    // We need to keep the empty array of options for the 'None' plugin as
    // it will be needed later.
    $option_values['validate']['options'] = [
      'none' => [],
    ];
    $option_values['validate']['fail'] = 'not found';
  }
  $sanitized_id = $option_values['validate']['type'];

  // Correct ID for js sanitized version.
  $option_values['validate']['type'] = $validate_id = static::decodeValidatorId($sanitized_id);
  $plugin = $this
    ->getPlugin('argument_validator', $validate_id);
  if ($plugin) {
    $options =& $option_values['validate']['options'][$sanitized_id];
    $plugin
      ->submitOptionsForm($form['validate']['options'][$sanitized_id], $form_state, $options);

    // Copy the now submitted options to their final resting place so they get saved.
    $option_values['validate_options'] = $options;
  }

  // Clear out the content of title if it's not enabled.
  if (empty($option_values['title_enable'])) {
    $option_values['title'] = '';
  }
}