Menu link content should remain mandatory

Created on 20 June 2025, 2 months ago

Problem/Motivation

In UI Icons Menu, https://git.drupalcode.org/project/ui_icons/-/blob/1.1.x/modules/ui_icon...

function ui_icons_menu_entity_base_field_info_alter(array &$fields, EntityTypeInterface $entity_type): void {
  ...
  // Icon is always optional.
  $fields['link']->setRequired(FALSE);
}

It removes the required on the link itself and then you get 🐛 Fatal error when the link in a menu item is empty Active :

Error: Call to a member function getUrl() on null in Drupal\menu_link_content\Entity\MenuLinkContent->getUrlObject() (line 104 of core/modules/menu_link_content/src/Entity/MenuLinkContent.php).

If you try to save a link with empty URI.

Proposed resolution

Link should remain required while icon optional.

🐛 Bug report
Status

Active

Version

1.1

Component

UI Icons Menu

Created by

🇫🇷France Grimreaper France 🇫🇷

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024