Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291555

Routes fail validation in link field widgets

$
0
0

You can add routes to a link field by using route:{$route_name}. However, if you save an entity with a link field that has a route and attempt to edit and re-save the node or menu item without changing the route in the link field, the route will fail validation.

Steps to reproduce

  1. Install a new Drupal site with the Standard profile.
  2. Go to /admin/structure/menu/manage/main/add
  3. Add a menu link to the frontpage view using its route. Enter anything for the title. The path should be route:view.frontpage.page_1. Save your link.
  4. Edit the menu link that you just created. Change the title. Note that the path is now view.frontpage.page_1 instead of route:view.frontpage.page_1. Attempt to save. Note a validation error: Manually entered paths should start with one of the following characters: / ? #

It looks like the code that makes routes fail validation was added to handle display of route:<nolink>:
https://github.com/drupal/drupal/blob/8.9.x/core/modules/link/src/Plugin...

However, route:<nolink> is handled later in the link widget code and other routes are not:
https://github.com/drupal/drupal/blob/8.9.x/core/modules/link/src/Plugin...

Luckily, there is an easy workaround for this bug. Each time you edit an entity with a link field that has a route, simply re-add the route: portion to your link.


Viewing all articles
Browse latest Browse all 291555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>