I want to add a custom tab after "Edit" but can't figure out how to do so. I added a mymodule.links.task.yml file

  route_name: entity.node.import_form
  base_route: entity.node.canonical
  title: Import JSON from file

But I don't understand what to do next. The node form just errors out with:

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.node.import_form" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 128 of /var/www/sites/datacenter.com/docroot/core/lib/Drupal/Core/Routing/RouteProvider.php).

  • Do you have defined entity.node.import_form in your $module.routing.yml file? – Daniel Wehner Apr 21 '15 at 14:15
  • 1
    I think I got confused looking at how Node adds an edit tab. I did not have a routing file, instead I looked at the node route provider class. – Kevin Apr 21 '15 at 15:19

What you have done is to create a menu task on the route entity.node.canonical with the title of Import JSON from file which links to the route entity.node.import_form.

The error you are getting is because the route entity.node.import_form (the link of the task) doesn't exist. You have to either depend/enable the module that provides this route or create the route yourself.

|improve this answer|||||
  • This answer could be improved by providing information or a link on how to create the route yourself as mymodule.links.task.yml would seem to be his attempt to create the route himself. – Mark May 13 '16 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.