private function GeofieldMapFieldTrait::setMapEmptyElement in Geofield Map 8
Same name and namespace in other branches
- 8.2 src/GeofieldMapFieldTrait.php \Drupal\geofield_map\GeofieldMapFieldTrait::setMapEmptyElement()
Set Map Empty Options Element.
Parameters
array $settings: The Form Settings.
array $elements: The Form element to alter.
1 call to GeofieldMapFieldTrait::setMapEmptyElement()
- GeofieldMapFieldTrait::generateGmapSettingsForm in src/
GeofieldMapFieldTrait.php - Generate the Google Map Settings Form.
File
- src/
GeofieldMapFieldTrait.php, line 456
Class
- GeofieldMapFieldTrait
- Class GeofieldMapFieldTrait.
Namespace
Drupal\geofield_mapCode
private function setMapEmptyElement(array $settings, array &$elements) {
$elements['map_empty'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Which behaviour for the empty map?'),
'#description' => $this
->t('If there are no entries on the map, what should be the output of field?'),
];
if (isset($this->fieldDefinition)) {
$elements['map_empty']['empty_behaviour'] = [
'#type' => 'select',
'#title' => $this
->t('Behaviour'),
'#default_value' => $settings['map_empty']['empty_behaviour'],
'#options' => $this->emptyMapOptions,
];
$elements['map_empty']['empty_message'] = [
'#type' => 'textfield',
'#title' => $this
->t('Empty Map Message'),
'#description' => $this
->t('The message that should be rendered instead on an empty map.'),
'#default_value' => $settings['map_empty']['empty_message'],
'#states' => [
'visible' => [
':input[name="fields[' . $this->fieldDefinition
->getName() . '][settings_edit_form][settings][map_empty][empty_behaviour]"]' => [
'value' => '1',
],
],
],
];
}
else {
$elements['map_empty']['empty_behaviour'] = [
'#type' => 'select',
'#title' => $this
->t('Behaviour'),
'#default_value' => $settings['map_empty']['empty_behaviour'],
'#options' => $this->emptyMapOptions,
];
}
}