From ebeda67be42f3851367ff3eb1c9a982c7eb411bd Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Fri, 17 Jun 2022 07:23:54 -0400 Subject: [PATCH] Recursively merge provided map settings into defaults. --- modules/core/map/src/Element/FarmMapInput.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/core/map/src/Element/FarmMapInput.php b/modules/core/map/src/Element/FarmMapInput.php index 0ce685a37..027119f03 100644 --- a/modules/core/map/src/Element/FarmMapInput.php +++ b/modules/core/map/src/Element/FarmMapInput.php @@ -58,20 +58,23 @@ class FarmMapInput extends FormElement { */ public static function processElement(array $element, FormStateInterface $form_state, array &$complete_form) { + // Recursively merge provided map settings into defaults. + $map_settings = array_merge_recursive([ + 'behaviors' => [ + 'wkt' => [ + 'edit' => TRUE, + 'zoom' => TRUE, + ], + ], + ], $element['#map_settings']); + // Define the map render array. // @todo Does this have to return a tree structure? $element['#tree'] = TRUE; $element['map'] = [ '#type' => 'farm_map', '#map_type' => $element['#map_type'], - '#map_settings' => [ - 'behaviors' => [ - 'wkt' => [ - 'edit' => TRUE, - 'zoom' => TRUE, - ], - ], - ], + '#map_settings' => $map_settings, ]; // Add a textarea for the WKT value.