1

I have the module.routing.yml as

entity.node.ssl_check:  
  path: '/node/{node}/check-ssl'  
  defaults:  
  _form: '\Drupal\ssl_check\Form\SslCheck'  
  _title: 'Check SSL Cert'  
  requirements:  
  _permission: 'access check ssl tab'  

and module.links.task.yml as

 entity.node.ssl_check:  
  route_name: entity.node.ssl_check  
  title: 'Ssl check'  
  base_route: entity.node.canonical  
  weight: 15  

Here when I access node/1104/check-ssl/ the form defined in the form controller is loading. But my other need that is to show a 'Ssl check' tab when I visit path /node/1104/ is not there. I have done the tab thing while dealing with Controller but not working with form controller. Please help. I have checked 'Add tab / local task to a node' this but there was nothing dealing with form controller.

2
  • The module.routing.yml file you are showing is not well-formed; it misses the indentation for defaults.
    – apaderno
    Jul 21, 2016 at 6:17
  • Also, as for creating local tasks, there isn't any difference between using a form or a controller: What you put in the .links.task.yml file is the same for both the cases.
    – apaderno
    Jul 21, 2016 at 6:40

4 Answers 4

2

Since everything looked just fine in your code, I tried the following in a custom module:

#test.links.task.yml
test.node_test:
   title: 'Wooorking'
   route_name: entity.node.canonical
   base_route: entity.node.canonical

And this is working like a charm. Also when I added a custom routing, which was pointing to a form controller, it showed up! (although not worked, because I didn't handled the node parameter in the routing configuration)

So the problem lies another where.

So I suggest you to do it step by step way (building your routing and task yml) to understand your problem. Clearing the cache each time when you change something in your YML files. If you found the problem, please post the solution, so also we can learn from this.

1

Apparently, if there's only one task, it won't appear. You'll watch the links appear if you add 2 or more links.

In other words, this wont appear alone :

entity.node.ssl_check:  
  route_name: entity.node.ssl_check  
  title: 'Ssl check'  
  base_route: entity.node.canonical  

This will show two tabs

entity.node.ssl_check:  
  route_name: entity.node.ssl_check  
  title: 'Ssl check'  
  base_route: entity.node.canonical  

entity.node.ssl_check2:  
  route_name: entity.node.ssl_check  
  title: 'Ssl check again'  
  base_route: entity.node.canonical  
0

Modified the code as

 entity.node.ssl_check:  
      title: Ssl check  
      route_name: entity.node.ssl_check  
      base_route: entity.node.canonical  
      weight: 15  
0
0

I had copied and pasted my code wrong. Things to check:

  • The file name is YOUR_MODULE.links.task.yml
  • The task name is YOUR_MODULE.some_task
  • The route name is YOUR_MODULE.some_route

The last one got me. It appears that if the route does not exist, the local task will silently not show.


File: YOUR_MODULE.links.task.yml

YOUR_MODULE.some_task
  title: 'Example Title'  
  route_name: YOUR_MODULE.manual_email
  base_route: YOUR_MODULE.manual_email

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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