2

I am developing a custom module for Drupal 8.0.1 which shows a custom form in admin/config/people/ban/settings.

admin/config/people/ban is the routes used by the Ban module. admin/config/people/ban/settings should be shown as Settings tab in that route, while the settings for the Ban module are shown in the Default tab.

How can I achieve this in my module?

3 Answers 3

3

For this you need to create a route in the module.routing.yml file

route_name:
  path: 'admin/config/people/ban/settings'
  defaults: 
    _form: '\Drupal\modulename\Form\FormController'
    -title: Form Title
  requirements:
    _permission: 'your permission string'

then you need to create another yml file with the name mymodule.links.menu.yml

add the following code

form_config_link:
  title: Configure Form Title
  description: 'Configuration Form description'
  parent: system.admin_config_people
  route_name: route_name //defined above

You need to check system module yml file for parent name

3

You need a local tasks menu link yml file, see example in node module: node.links.task.yml

2
  • This is my module.links.menu.yml file
    – user15837
    Jan 18, 2016 at 12:59
  • Can you provide a working example? Jan 18, 2016 at 13:23
0

The trick is that always need at least two local tasks for local tasks to show up. They don't do if there's only one.

So, define a yourmodule.menu.task.yml and put two definitions in there. Default, which has the existing ban route for both base_route and route_name and yours, which has your route_name and the same base_route as the the default task.

What used to be the default task in Drupal 7 is now simply the task that has base_route == route_name.

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.