public function LeafletMap::validateOptionsForm in Leaflet 8
Same name and namespace in other branches
- 2.1.x modules/leaflet_views/src/Plugin/views/style/LeafletMap.php \Drupal\leaflet_views\Plugin\views\style\LeafletMap::validateOptionsForm()
- 2.0.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 612
Class
- LeafletMap
- Style plugin to render a View output as a Leaflet map.
Namespace
Drupal\leaflet_views\Plugin\views\styleCode
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.'));
}
$icon_options = isset($style_options['icon']) ? $style_options['icon'] : [];
if (!empty($icon_options['iconSize']['x']) && (!is_numeric($icon_options['iconSize']['x']) || $icon_options['iconSize']['x'] <= 0)) {
$form_state
->setError($form['icon']['iconSize']['x'], $this
->t('Icon width needs to be a positive number.'));
}
if (!empty($icon_options['iconSize']['y']) && (!is_numeric($icon_options['iconSize']['y']) || $icon_options['iconSize']['y'] <= 0)) {
$form_state
->setError($form['icon']['iconSize']['y'], $this
->t('Icon height needs to be a positive number.'));
}
}