When adding a menu ( admin/structure/menu/add ) you get the machine name from the title input field, using misc/machine-name.js. The actual machine name that is stored in the database adds 'menu_' as a prefix to the visible machine name on the form though (as visible if you save the menu and then edits it to see the machine name).
My thought is that an extra string argument 'prefix' could be added to the call to Drupal.behaviors.machineName.attach that will be added to the machine name, then the menu module could be updated to send 'menu' as a prefix when calling machineName.attach ($form['menu_name'] in menu.admin.inc).
Comment | File | Size | Author |
---|---|---|---|
#12 | add_menu_to_machine_name-1288910-12.patch | 519 bytes | tinko |
#9 | add-menu-machine-name-1288910-9.patch | 1.19 KB | Rajender Rajan |
#5 | add_menu_machine_name-1288910-5.patch | 2.78 KB | FreddieK |
#3 | add_menu_machine_name-1288910-3.patch | 1.67 KB | FreddieK |
#1 | add_menu_machine_name-1288910-1.patch | 1.14 KB | FreddieK |
Comments
Comment #1
FreddieK CreditAttribution: FreddieK commentedHere's a patch that does what's outlined above:
(not working, see next comment)
Comment #2
FreddieK CreditAttribution: FreddieK commentedI noticed that the patch has the unlucky result that 'menu-' now gets added twice to the machine name, so no disco. But is the approach a good one or should this be solved in a different way?
Comment #3
FreddieK CreditAttribution: FreddieK commentedFixed patch.
Comment #4
joachim CreditAttribution: joachim commentedThis seems like a good idea, but this new key needs to be added to the documentation for Drupal.behaviors.machineName.
Some other points:
Remember to trim whitespace.
This needs indenting.
Move this comment to the 'prefix' item, as the reason we need a prefix still needs explaining.
4 days to next Drupal core point release.
Comment #5
FreddieK CreditAttribution: FreddieK commentedUpdated patch.
Comment #6
Bathie CreditAttribution: Bathie commentedHello, I tested the patch, it is good
Comment #7
mgiffordPushing to needs review. I think that's what's missing here.
Comment #9
Rajender Rajan CreditAttribution: Rajender Rajan as a volunteer and at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedComment #10
Rajender Rajan CreditAttribution: Rajender Rajan as a volunteer and at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedComment #12
tinko CreditAttribution: tinko as a volunteer commentedHello,
In misc/machine-name.js has a short documentation about the properties and there is already field_prefix that will show before menu name if the #field_prefix is added to field "menu_name".
Greetings
Comment #13
ethomas08 CreditAttribution: ethomas08 as a volunteer commentedIs this issue the same as this one?? https://www.drupal.org/project/drupal/issues/2021571
The patch for the other issue looks good. It adds the menu- to the menu name when adding a new menu.
Comment #14
poker10 CreditAttribution: poker10 at ActivIT s.r.o. commentedThis is indeed a duplicate of #2021571: preview of menu machine name is inaccurate on while adding a menu (does not show it will be saved with menu- prefix) and it should be fixed in 7.92 release. Thanks!