You are here

public function SimpleSitemapDisplayExtender::validateOptionsForm in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 4.x modules/simple_sitemap_views/src/Plugin/views/display_extender/SimpleSitemapDisplayExtender.php \Drupal\simple_sitemap_views\Plugin\views\display_extender\SimpleSitemapDisplayExtender::validateOptionsForm()

Validate the options form.

Overrides DisplayExtenderPluginBase::validateOptionsForm

File

modules/simple_sitemap_views/src/Plugin/views/display_extender/SimpleSitemapDisplayExtender.php, line 195

Class

SimpleSitemapDisplayExtender
Simple XML Sitemap display extender plugin.

Namespace

Drupal\simple_sitemap_views\Plugin\views\display_extender

Code

public function validateOptionsForm(&$form, FormStateInterface $form_state) {
  if ($this
    ->hasSitemapSettings() && $form_state
    ->get('section') == 'simple_sitemap') {
    $required_arguments = $this
      ->getRequiredArguments();
    foreach (array_keys($this->variants) as $variant) {
      $arguments =& $form_state
        ->getValue([
        'variants',
        $variant,
        'arguments',
      ], []);
      $arguments = array_merge($arguments, $required_arguments);
      $errors = $this
        ->validateIndexedArguments($arguments);
      foreach ($errors as $message) {
        $form_state
          ->setError($form['variants'][$variant]['arguments'], $message);
      }
    }
  }
}