How to add link to custom module configuration form in Drupal 8

by emersonthis   Last Updated November 12, 2017 03:07 AM

I'm working on a custom module that has a couple configuration form for controlling it's settings. I want to add a link to this form to the admin configuration UI. The new link to my settings isn't appearing, but the form works fine if I navigate directly to it using the URL.

# stripedonation.links.menu.yml

stripedonation.admin:
  title: 'Stripe Donation'
  description: 'Manage settings for strip donations'
  parent: system.admin_config_system
  # menu_name: main
  route_name: stripedonation.settings
  weight: 1

NOTE: I cleared the cache after adding this.

# stripedonation.routing.yml

stripedonation.settings:
  path: '/admin/config/stripedonation'
  defaults:
    _form: '\Drupal\stripedonation\Form\SettingsForm'
    _title: 'Stipe Donation Settings'
  requirements:
    _permission: 'administer site config'

I also tried adding the key shown below to my *.info.yml file and it didn't help

# stripedonation.info.yml

name: "Stripe Donation"
type: module
description: "Adds Stripe Donation form for ThinkShout vetting exercrise"
package: EmersonThis
core: 8.x
# configure: stripedonation.settings

In case it matters...

# stripedonation.settings.yml
stripe_pub_key: ''
stripe_secret_key: ''

I'm expecting my menu link to show up here (but obviously it is not): enter image description here

I've studied the following documentation:

I've also studied every "how-to" I could find:

Still no menu in the admin UI. What am I doing wrong?

Tags : 8 forms navigation


Answers 1


Well it turned out to be a stupid mistake!

All of my filenames and syntax were correct, but my *.links.menu.yml accidentally was saved into the src/ directory of my module instead of at the root of it. I moved it where it should be and cleared the cache and it works fine.

emersonthis
emersonthis
November 12, 2017 02:30 AM

Related Questions


How to add field to menu

Updated January 10, 2017 08:03 AM



No navigation links on 404 pages

Updated February 05, 2017 14:03 PM