Menu names use hyphens, but most other machine names use underscores. We should decide on a standard.
If we can standardize on machine names, then we can also standardize on token names, see #1302056: Standardize on use of underscore vs hyphen in tokens
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | menus-hyphens.JPG | 51.23 KB | ericyellin |
Comments
Comment #1
jenlamptonTagging for learnability :)
Comment #2
eojthebraveI think we should standardize on underscores rather than hyphens as hyphens do to translate nicely to PHP variable or function names.
Comment #3
dawehnerAfaik we have standardized on underscores now.
Comment #5
dreftymac commentedSee also:
* Related post on do ;; https://www.drupal.org/node/1302056
* Related post on do ;; https://www.drupal.org/node/1343228
* Related DDG search ;; https://duckduckgo.com/?q=drupal+dash+vs+hyphen+-lodash&t=h_&ia=web
* Comparison to Django ;; http://stackoverflow.com/questions/427102/what-is-a-slug-in-django
Comment #6
ericyellin commentedThis still seems to be an issue on Drupal 8.5.4 release.
It seems that only menus use hyphens while everywhere else underscores are used.
This causes issues with modules that expect underscores and disallow hyphens.
Also had an issue with menus that were created with underscores (maybe an older version with no validation) and now cannot be edited and saved since while saving it validates and prevents underscores.
This is not fixed... See screenshot.
Comment #7
ericyellin commentedThis still seems to be an issue on Drupal 8.5.4 release.

It seems that only menus use hyphens while everywhere else underscores are used.
This causes issues with modules that expect underscores and disallow hyphens.
Also had an issue with menus that were created with underscores (maybe an older version with no validation) and now cannot be edited and saved since while saving it validates and prevents underscores.
This is not fixed...
Here is the mesa
Comment #8
bdanin commentedI'm having this same issue with menus in Drupal 8.7.3
I have old menus installed from a previous version and all the machine names are using underscores. However, if I add a new menu to the site it uses hyphens now by default. And when trying to edit an existing menu, I'm getting the same errors shown in previous comments meaning I can't re-order menus through the UI, only directly in code with config-management. Why do menus use hyphens, see this thread for example: https://drupal.stackexchange.com/questions/206067/use-underscores-in-men...
This is a major issue in my opinion and menus should use underscores like before and the rest of Drupal machine names.
Comment #9
anruether