You are here

public function LeafletMap::validateOptionsForm in Leaflet 2.0.x

Same name and namespace in other branches
  1. 8 modules/leaflet_views/src/Plugin/views/style/LeafletMap.php \Drupal\leaflet_views\Plugin\views\style\LeafletMap::validateOptionsForm()
  2. 2.1.x modules/leaflet_views/src/Plugin/views/style/LeafletMap.php \Drupal\leaflet_views\Plugin\views\style\LeafletMap::validateOptionsForm()

Validate the options form.

Overrides StylePluginBase::validateOptionsForm

File

modules/leaflet_views/src/Plugin/views/style/LeafletMap.php, line 615

Class

LeafletMap
Style plugin to render a View output as a Leaflet map.

Namespace

Drupal\leaflet_views\Plugin\views\style

Code

public function validateOptionsForm(&$form, FormStateInterface $form_state) {
  parent::validateOptionsForm($form, $form_state);
  $style_options = $form_state
    ->getValue('style_options');
  if (!empty($style_options['height']) && (!is_numeric($style_options['height']) || $style_options['height'] <= 0)) {
    $form_state
      ->setError($form['height'], $this
      ->t('Map height needs to be a positive number.'));
  }
}