No link template 'canonical' found for the 'menu' entity type

Created on 30 November 2017, over 6 years ago
Updated 1 September 2023, 10 months ago

Problem/Motivation

When you try to save view modes settings for menu an error is occurred.

Steps to reproduce:

  • Enable menu_item_extras module to provide view mode settings
  • Add link to any menu
  • Go to manage display of that menu and click on View Modes Settigs
  • Save the view mode
  • Get the following error message:
The website encountered an unexpected error. Please try again later.

Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: No link template 'canonical' found for the 'menu' entity type in Drupal\Core\Entity\Entity->toUrl() (line 215 of core/lib/Drupal/Core/Entity/Entity.php).
Drupal\Core\Config\Entity\ConfigEntityBase->toUrl('canonical') (Line: 270)
Drupal\Core\Entity\Entity->toLink(Object) (Line: 126)
Drupal\menu_item_extras\MenuItemExtrasViewModesSettingsForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('menu_view_modes_settings_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('menu_view_modes_settings_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 576)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed resolution

To add additional check in ConfigEntityBase->toUrl method to check if $rel value is 'canonical' and replace it with 'edit-form'.

🐛 Bug report
Status

Needs work

Version

9.5

Component
Menu system 

Last updated 1 day ago

Created by

🇧🇬Bulgaria lmarkov

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • 🇮🇳India Nishant2312

    As per the steps to reproduce the issue

    The updated module menu_item_extras is working properly

    Please check this after saving the menu link and selecting the menu manage display form.

    Here Below I have attached the module details for your reference.

    Drupal Version: 9.5.10

    Menu Item Extras 3.0.2

    If the issue still persists, please let me know

  • 🇩🇪Germany tstoeckler Essen, Germany

    Linking related issues here. The second one would fix this issue, as well, as far as I can tell.

Production build 0.69.0 2024