0

Can i use route ID for Link template 'edit-form' for entity type?

I'm following this tutorial

over there he use:

 *   links = {
 *     "edit-form" = "flower.edit",
 *     "delete-form" = "flower.delete"
 *   }

while flower.edit (i assume) is from below route.yml:

flower.edit:
  path: '/admin/structure/flowers/edit/{flower}'
  defaults:
    _entity_form: 'flower.edit'
    _title: 'Edit flower'
  requirements:
    _permission: 'administer site configuration'

but when i run, it throw me an error:

Uncaught PHP Exception Drupal\Core\Entity\Exception\InvalidLinkTemplateException: "Link template 'edit-form' for entity type 'flower' must start with a leading slash, the current link template is 'flower.edit'" at \core\lib\Drupal\Core\Entity\EntityTypeManager.php line 97

I know i can just use: /admin/structure/flowers/edit/{flower} to solve my problem.

but the question is: is it actually possible to use route (instead of path) in entity links config?

3
  • The tutorial is from 2014, since then the form links have changed from routes to paths.
    – 4k4
    Mar 26 '17 at 14:35
  • so, the answer is: not possible, it can only accept paths?
    – AnD
    Mar 26 '17 at 14:37
  • 1
    See change record drupal.org/node/2382937
    – 4k4
    Mar 26 '17 at 14:42
2

The tutorial is from 2014. Since then the link templates have changed from route to path. See change record:

Previous link template format

   links = {
     "canonical" = "entity.node.canonical",
     "edit-form" = "entity.node.edit_form",
     "delete-form" = "entity.node.delete_form",
   }

New link template format

After the change, the path is used.

   links = {
     "canonical" = "/node/{node}",
     "edit-form" = "/node/{node}/edit",
     "delete-form" = "/node/{node}/delete",
   }

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .