0

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?

  • Did you clear the cache after adding the menu.yml? – Kevin Nov 12 '17 at 2:20
  • @Kevin Good question. Yes, I did make sure to clear the cache – emersonthis Nov 12 '17 at 2:20
  • There are no typos in the filename correct? For the yaml files? – Kevin Nov 12 '17 at 2:23
  • You might just be missing menu_name: admin in the link definition – Clive Nov 12 '17 at 2:29
  • @Kevin The filenames were correct, but as I was double-checking them I found the problem. (See below) Your line of questioning lead me to the solution so if you submit an answer I'll accept it. – emersonthis Nov 12 '17 at 2:31
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.

  • 1
    Yep, it happens in the beginning. Once you get your feet wet some more, look into using Drupal Console to generate this stuff. – Kevin Nov 12 '17 at 5:04

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.