Adding link to menu leads to Class "Drupal\link\Plugin\Field\FieldWidget\ObjectClass" not found in Drupal\link\Plugin\Field\FieldWidget\LinkWidget::getUserEnteredStringAsUri()

Created on 28 February 2024, 10 months ago
Updated 3 July 2024, 6 months ago

Problem/Motivation

Adding custom links to menu is not possible. It leads to:

Class "Drupal\link\Plugin\Field\FieldWidget\ObjectClass" not found in Drupal\link\Plugin\Field\FieldWidget\LinkWidget::getUserEnteredStringAsUri() error (line 143 of core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php). Drupal\link\Plugin\Field\FieldWidget\LinkWidget::validateUriElement() call_user_func_array() (Line: 282)

PHP version: 8.1.27
MySQL: 8.0
Drupal core: 10.1.8

Steps to reproduce

  • Navigate to Admin->Structure->Menu->Edit
  • Click on "Add link" button
  • Add link with the following syntax "/node-name"

Proposed resolution

I will provide a patch in a separate comment below

πŸ› Bug report
Status

Closed: duplicate

Version

10.1 ✨

Component
Menu systemΒ  β†’

Last updated about 1 hour ago

Created by

πŸ‡§πŸ‡¬Bulgaria rastepanyan

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

Comments & Activities

Production build 0.71.5 2024