Skip to content
Snippets Groups Projects

Merge array recursive

@@ -9,6 +9,7 @@ use Drupal\Component\Utility\Unicode;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\menu_link_content\MenuLinkContentInterface;
use Drupal\Component\Utility\NestedArray;
/**
* Implements hook_form_BASE_FORM_ID_alter().
@@ -187,8 +188,9 @@ function menu_link_attributes_menu_link_content_form_entity_builder($entity_type
$menu_link_options = $original->get('link')->first()->options;
}
// Merge with existing options:
$existing_options = $menu_link->link->first()->options;
$menu_link->link->first()->options = array_merge($existing_options, $menu_link_options);
$menu_link->link->first()->options = NestedArray::mergeDeep($existing_options, $menu_link_options);
// Set for other languages.
if ($menu_link->isDefaultTranslation() || !$menu_link->isDefaultTranslationAffectedOnly()) {
Loading