You are here

protected function LeafletSettingsElementsTrait::generateWeightElement in Leaflet 2.1.x

Same name and namespace in other branches
  1. 2.0.x src/LeafletSettingsElementsTrait.php \Drupal\leaflet\LeafletSettingsElementsTrait::generateWeightElement()

Generate the weight Form Element.

Parameters

string $weight: The weight string definition.

Return value

array The Leaflet weight Form Element.

2 calls to LeafletSettingsElementsTrait::generateWeightElement()
LeafletDefaultFormatter::settingsForm in src/Plugin/Field/FieldFormatter/LeafletDefaultFormatter.php
Returns a form to configure settings for the formatter.
LeafletMap::buildOptionsForm in modules/leaflet_views/src/Plugin/views/style/LeafletMap.php
Provide a form to edit options for this plugin.

File

src/LeafletSettingsElementsTrait.php, line 334

Class

LeafletSettingsElementsTrait
Class LeafletSettingsElementsTrait.

Namespace

Drupal\leaflet

Code

protected function generateWeightElement($weight) {
  $default_settings = $this::getDefaultSettings();
  return [
    '#title' => $this
      ->t('weight / zIndex Offset'),
    '#type' => 'textfield',
    '#size' => 30,
    '#description' => $this
      ->t('This option supports <b>Replacement Patterns</b> and should end up into an Integer (positive or negative value).<br>This will apply to each Leaflet Feature/Marker result, and might be used to dynamically set its position/visibility on top (or below) of each others.'),
    '#default_value' => isset($weight) ? $weight : $default_settings['weight'],
  ];
}