Recursively merge provided map settings into defaults.

This commit is contained in:
Michael Stenta 2022-06-17 07:23:54 -04:00
parent 70e8b1f9ea
commit ebeda67be4
1 changed files with 11 additions and 8 deletions

View File

@ -58,20 +58,23 @@ class FarmMapInput extends FormElement {
*/ */
public static function processElement(array $element, FormStateInterface $form_state, array &$complete_form) { 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. // Define the map render array.
// @todo Does this have to return a tree structure? // @todo Does this have to return a tree structure?
$element['#tree'] = TRUE; $element['#tree'] = TRUE;
$element['map'] = [ $element['map'] = [
'#type' => 'farm_map', '#type' => 'farm_map',
'#map_type' => $element['#map_type'], '#map_type' => $element['#map_type'],
'#map_settings' => [ '#map_settings' => $map_settings,
'behaviors' => [
'wkt' => [
'edit' => TRUE,
'zoom' => TRUE,
],
],
],
]; ];
// Add a textarea for the WKT value. // Add a textarea for the WKT value.