1

I want to have tabs, but since they need to be dynamic I am making use of local tasks. In the class extending DeriverBase I have written the following function:

public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = array();
    foreach ($this->moduleFormatManager->getDefinitions() as $key => $definition) {
      $this->derivatives[$key]['title'] = $definition['title'];
      $this->derivatives[$key]['route_parameters'] = array('module_format' => $key);
      $this->derivatives[$key]['route_name'] = 'module.format_configure_' . $key;
      if($key == 'xyz') {
        $key = 'newkey';
      $this->derivatives[$key]['title'] = 'newkey';
      $this->derivatives[$key]['route_name'] = 'module.newkey';
      $this->derivatives[$key]['parent_id'] = "module.format_configure:xyz";
      }
    }
    foreach ($this->derivatives as &$entry) {
      $entry += $base_plugin_definition;
    }
    return $this->derivatives;
  }

In the above code, a tab for each key is being generated: my problem is in the if condition. In the if condition I am trying to generate a sub tab for a particular type of tab by declaring parent_id. But the code doesn't work for me.

What changes should I introduce in order to make it work? I used this link to learn about local tasks.

My module.links.tasks.yml file looks like this:

module.format_configure:
  title: 'Configuration'
  base_route: module.configure
  tab_root_id: module.configure
  deriver: 'path to deriver'

All the mentioned routes have been declared in *.routing.yml file.

6
  • Have a look at how Field UI is doing it.
    – user21641
    Jul 3, 2015 at 9:27
  • @IvanJaros I have already looked in that module but couldn't find my mistake hence asking here. Jul 3, 2015 at 10:46
  • Have you properly set the class and deriver in your module's links.task.yml file?
    – user21641
    Jul 3, 2015 at 13:30
  • @IvanJaros I have updated my answer with the expected code in my links.tasks.yml file. Jul 3, 2015 at 14:07
  • How is the behaviour happening in the UI directl/ Jul 4, 2015 at 21:36

1 Answer 1

1

You said your file is called module.links.tasks.yml. The correct filename is module.links.task.yml (note links word is pluralized, but task is not).

Your Answer

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

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