Problem/Motivation

Menu edit forms entity.menu.edit_form and menu_ui.link_edit have already an option enable and disable menu items. On node forms (add/edit/translate) the enable option is missing.

There's multiple reasons to create the menu item but disable it:
- hierarchical path structures based on menu items
- mega menu's

Proposed resolution

Add enable option also to node forms.

Remaining tasks

- Patch with RTBC status.

User interface changes

Before:

node form before the patch

After:

form after the patch

API changes

-

Data model changes

-

Release notes snippet

-

CommentFileSizeAuthor
#68 3075230-68.patch11.33 KBmartinpe
#58 interdiff_57-58.txt1.11 KBvsujeetkumar
#58 3075230-58.patch10.88 KBvsujeetkumar
#57 3075230-57.patch10.93 KB_utsavsharma
#57 interdiff_56-57.txt10.93 KB_utsavsharma
#56 provide-menu-link-with-disable-option-3075230-56.patch10.94 KBmanvinder12
#51 After Patch.png60.62 KBprasanth_kp
#51 Before Patch.png77.07 KBprasanth_kp
#48 3075230-48.patch2.36 KBnikhil_110
#42 Afterpatch.png29.33 KBakhildev.cs
#42 BeforePatchNode.png23.67 KBakhildev.cs
#41 3075230-after-patch.png18.19 KBdevashish jangid
#41 3075230-before-patch.png16.05 KBdevashish jangid
#40 interdiff_39-40.txt473 bytessokru
#40 3075230-40.patch11.77 KBsokru
#39 interdiff_38-39.txt1.1 KBsokru
#39 3075230-39.patch11.95 KBsokru
#38 interdiff_37-38.txt487 bytesravi.shankar
#38 3075230-38.patch11.94 KBravi.shankar
#37 3075230-37.patch11.97 KBsokru
#35 3075230-35.patch11.89 KBnsalves
#29 3075230-29.patch11.89 KBrichardgaunt
#28 3075230-28.patch11.89 KBrichardgaunt
#27 menu-ui-content-type-menu-configuration-form.png84.96 KBrichardgaunt
#27 menu-ui-enable-link.png30.7 KBrichardgaunt
#27 3075230-27.patch11.89 KBrichardgaunt
#25 interdiff_24-25.txt1.4 KBvsujeetkumar
#25 3075230-25.patch6.17 KBvsujeetkumar
#24 3075230-23.patch6.38 KBrichardgaunt
#22 3075230-21.patch3.66 KBranjith_kumar_k_u
#21 After_patch.png28.41 KBvikashsoni
#21 Before_patch.png22.35 KBvikashsoni
#19 Bydefault Disabled_unchecked displayed.png63.6 KBmanojithape
#19 After patch menu enabled option present on Edit form.png70.62 KBmanojithape
#19 After patch Menu Ebnable option present on Add Form.png65.08 KBmanojithape
#19 Before patch Menu Enable option not present.png64.03 KBmanojithape
#17 3075230-17.patch3.66 KBrichardgaunt
#17 menu_ui_3rd_party_setting.png50.77 KBrichardgaunt
#15 3075230-15.patch2.33 KBchrissnyder
#14 3075230-before_patch.png40.13 KBabhijith s
#14 3075230-after_patch.png37.77 KBabhijith s
#9 interdiff-6-9.txt1.03 KBaleevas
#9 3075230-9.patch2.33 KBaleevas
#6 3075230-6.png36.25 KBaleevas
#6 interdiff-2-6.txt1.16 KBaleevas
#6 3075230-6.patch2.36 KBaleevas
#2 enable-disable-menu-item-link-via-node-add-form.patch1.69 KBabhaysaraf
menu_enable.png73.12 KBabhaysaraf

Issue fork drupal-3075230

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

abhaysaraf created an issue. See original summary.

abhaysaraf’s picture

hussainweb’s picture

Status: Active » Needs review

@abhaysaraf, can you please put a screenshot with the new checkbox? This also needs tests.

hussainweb’s picture

Priority: Minor » Normal

Status: Needs review » Needs work
aleevas’s picture

Version: 8.7.x-dev » 8.8.x-dev
Issue tags: +Needs tests
StatusFileSize
new2.36 KB
new1.16 KB
new36.25 KB

Just fixed a failed test from #2
Also attached a screenshot with this checkbox
The flag

hussainweb’s picture

Something I realised from the test-fail. Is the "Enabled" checkbox checked by default when the page loads? I think that would be a good idea.

+++ b/core/modules/menu_ui/menu_ui.module
@@ -304,6 +305,13 @@ function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) {
+    '#default_value' => isset($defaults['enabled']) ? $defaults['enabled'] : 1,

This could be simplified to $defaults['enabled'] ?? 1

hussainweb’s picture

Or even just (bool) $defaults['enabled'].

aleevas’s picture

Status: Needs work » Needs review
StatusFileSize
new2.33 KB
new1.03 KB

hussainweb thanks for your advise. Your notice make sense.
Made changes in this patch

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

bohus ulrych’s picture

Hi, thank you for your work. It works like charm - tested previously with 9.0.x and now with 9.1.0

Btw: for D7 I used https://www.drupal.org/project/disable_node_menu_item, for D8 https://www.drupal.org/sandbox/pcranston/2920832. Now I'm happy with this simple, clean core patch.

abhijith s’s picture

StatusFileSize
new37.77 KB
new40.13 KB

Applied patch on 9.2.x and it works.The checkbox for showing menu items appears after this patch and it works well.Adding screenshots.

Before:
before

After:
after

chrissnyder’s picture

StatusFileSize
new2.33 KB

I was having an issue with the patch in #9 when some of the content types did not show the menu on the node edit form. The attached patch corrects this.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

richardgaunt’s picture

StatusFileSize
new50.77 KB
new3.66 KB

I've expanded on patch #15 default enable link to the node type form, so that this setting can be have defaults defined for each content type.

I should also note, the above patches were exactly the feature I was looking nice work.

manojithape’s picture

Assigned: Unassigned » manojithape
manojithape’s picture

Verified and tested patch#17 on the drupal 9.3.x-dev version. Patch applied successfully But found one observation.

Testing Steps:

  1. Install drupal 9.3.x-dev version.
  2. Login as Administrator
  3. Observe the "Menu link Enable/disable the checkbox" is not present on the Add/Edit form of any default content type (Article or basic page) or custom content type under the Menu Setting option.
  4. Apply patch and
  5. Verify "Menu link Enable/disable the checkbox" is provided on the Add/Edit form of any default content type (Article or basic page) or custom content type under the Menu Setting option.
  6. Verify as per the Status menu link enable/disable.
  7. Verify bydefault Status of menu link should display enable.

Expected Result:

  1. The "Menu link Enable/disable the checkbox" option should be provided on the Add/Edit form of any default content type (Article or basic page) or custom content type under the Menu Setting option.
  2. As per the Status of the checkbox menu, the link should enable/disable.
  3. Bydefault Status of menu link should display enable.

Actual Results:

  1. The "Menu link Enable/disable the checkbox" option is provided on the Add/Edit form of any default content type (Article or basic page) or custom content type under the Menu Setting option.
  2. As per the Status of the checkbox menu, the link is enable/disable and working fine
  3. Bydefault Status of menu link display disabled.

Observation:
By default status of the menu link displayed "disabled/unchecked" for all content types. It should Enable by default. Please refer attached screenshot (Bydefault Disabled_unchecked displayed.png ).

manojithape’s picture

Assigned: manojithape » Unassigned
vikashsoni’s picture

StatusFileSize
new22.35 KB
new28.41 KB

patch#17 working fine and applied cleanly for reference sharing screenshot ...
Thanks

ranjith_kumar_k_u’s picture

StatusFileSize
new3.66 KB

Fixed CS error

Status: Needs review » Needs work

The last submitted patch, 22: 3075230-21.patch, failed testing. View results

richardgaunt’s picture

StatusFileSize
new6.38 KB

What has changed

1. Updated failing test for new menu_link options in node form.
2. Fixed issue found in: #19 - checkbox is now checked if no setting has been configured.
3. Updated JS to hide the menu link enabled, if no menus are selected

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new6.17 KB
new1.4 KB

Fixed the custom command fail issues.

Status: Needs review » Needs work

The last submitted patch, 25: 3075230-25.patch, failed testing. View results

richardgaunt’s picture

Issue summary: View changes
StatusFileSize
new11.89 KB
new30.7 KB
new84.96 KB

What has changed

1. Added tests to check the content type configuration option.
2. Updated node form tests, to test the enable link functionality.

richardgaunt’s picture

Issue summary: View changes
StatusFileSize
new11.89 KB

Fixed lint issue.

richardgaunt’s picture

Issue tags: -Needs tests
StatusFileSize
new11.89 KB
richardgaunt’s picture

Status: Needs work » Needs review

stefanos.petrakis made their first commit to this issue’s fork.

stefanos.petrakis’s picture

Version: 9.3.x-dev » 9.4.x-dev

Picking this up for review in a MR, commited the most important patches from the issue for easier tracking of history.

Switched to 9.4.x-dev (and updated code from #29 accordingly)

Keeping #29 visible (applies to 9.3); hiding all other patches and interdiffs.

stefanos.petrakis’s picture

Status: Needs review » Needs work

My review on this FWIW, with the hope this moves on, it's a wonderful feature.

nsalves’s picture

StatusFileSize
new11.89 KB

Patch #29 was not applying in core 9.3.5 (some changes to the two js files it patches). Leaving the same patch updated for that version here in case anyone needs this.

micnap’s picture

Thanks for the 9.3 patch @Nelson Alves. Applied and works well in 9.3.9.

sokru’s picture

Status: Needs work » Needs review
StatusFileSize
new11.97 KB

This is patch against 9.4.x. I rerolled the MR and made the suggested corrections. Only thing I couldn't figure out was the note about logical error on https://git.drupalcode.org/project/drupal/-/merge_requests/1443#note_57563.

I tested this on local, works fine and is useful feature.

ravi.shankar’s picture

StatusFileSize
new11.94 KB
new487 bytes

Fixed Drupal CS issue of patch #37.

sokru’s picture

StatusFileSize
new11.95 KB
new1.1 KB

Included patch should resolve "Custom commands failed".

sokru’s picture

StatusFileSize
new11.77 KB
new473 bytes

Maybe now the CI bot is happy.

devashish jangid’s picture

StatusFileSize
new16.05 KB
new18.19 KB

Verified and tested patch #40.
Patch applied successfully and looks good for me.
Sharing screenshots for the reference.

akhildev.cs’s picture

StatusFileSize
new23.67 KB
new29.33 KB

Hi,
Applied patch #40 is working fine.
Thank you for the patch.

kdborg@gmail.com’s picture

I'm using patch #35 with Drupal 9.3.9. I'm not seeing the "Enabled" option on the node edit form.

This patch works if I start a brand new website. If I use the one I'm testing on, there is no "Enabled" option.

andypost’s picture

Status: Needs review » Needs work
Issue tags: -menu, -node +Needs upgrade path, +Needs upgrade path tests, +JavaScript

Merge request is outdated, patch missing upgrade path

richardgaunt’s picture

The feature provides the ability to create node's with a menu link that is disabled. What upgrade path would we be providing?

kdborg@gmail.com’s picture

The module "Menu Link" disables the Menu UI module from adding to the node edit page.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nikhil_110’s picture

Issue summary: View changes
StatusFileSize
new2.36 KB

Rerolled patch against 9.5.x

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nikhil_110’s picture

Status: Needs work » Needs review
prasanth_kp’s picture

StatusFileSize
new77.07 KB
new60.62 KB

Applied #48 patch on 10.1.x-dev and it works.

stefanos.petrakis’s picture

Status: Needs review » Needs work

Trying to update the PR, against 10.1.x and also including all the work that went into patch #40.

Regarding patch #48: Why is this patch missing so many of the changes from #40 if it is a reroll?
Gonna set this back to 'Needs work' till this gets clarified.

rkoller’s picture

In the process of writing up a separate issue about the manage form display page i've noticed the problem and inconsistency this issue is going to solve. thanks for working on that! but one detail aside the points mentioned in #52 the issue also needs an issue summary. at the moment there isn't any at all anymore.

sokru’s picture

Issue summary: View changes

I think re-roll at #48 was mistake, its missing tests etc, my suggestion is to ignore it for now.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

manvinder12’s picture

Re roll of #40 for Drupal 10.1.4

_utsavsharma’s picture

StatusFileSize
new10.93 KB
new10.93 KB

Patch for 11.x.

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new10.88 KB
new1.11 KB

Fixed the failed test cases, Please have a look.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs upgrade path, +Needs upgrade path tests

New schema will require an upgrade path

+    // Configure menu links to be disabled.
+    $edit = [
+      'menu_options[main]' => 1,
+      'menu_parent' => 'main:',
+      'link_enabled' => FALSE,
+    ];
+    $this->drupalGet('admin/structure/types/manage/page');
+    $this->submitForm($edit, 'Save');
+    $this->assertSession()->pageTextContains('The content type Basic page has been updated.');

Don't think all this is needed. Just using the config service should work. Unless there is testing of a new configuration option, which is missing.

programmerdiego’s picture

@vsujeetkumar
@_utsavsharma
@manvinder12
vsujeetkumar
_utsavsharma
manvinder12
Your patch did not work for:
Drupal Version 10.1.5
MySQL Version 5.7.29
PHP 8.1.14

SakaSerbia’s picture

crutch’s picture

@19, we should be able to set the default as disabled or enabled per content type

dieterholvoet made their first commit to this issue’s fork.

dieterholvoet changed the visibility of the branch 11.x to hidden.

dieterholvoet changed the visibility of the branch drupal-3075230-3075230-provide-menu-link to hidden.

dieterholvoet’s picture

I created a new MR on 11.x and rebased the existing changes.

martinpe’s picture

StatusFileSize
new11.33 KB

Adapted the patch 3075230-58.patch for Drupal 11.1.x

quadrexdev made their first commit to this issue’s fork.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave changed the visibility of the branch 3075230-provide-menu-link to hidden.

smustgrave’s picture

Rebased this one but seems will still need upgrade path.

anybody made their first commit to this issue’s fork.

kthull’s picture

The latest patch from MR 11618 is needed for D11.4.x, but disabling the menu item in the node edit form no longer saves the unchecked value. So unchecking and saving keeps the menu item in the menu, and editing the node again shows the Enabled checkbox as checked. Worse: it prints the full menu for disabled menu items, and in our case we need the specific child-level menu on disabled menu items.

ETA: Did some further testing and the patch from #68 works as expected on D11.3.x but fails to install for D11.4.x so it looks like I'll be downgrading to D11.3.x until this is fixed.

smustgrave’s picture

Component: menu system » menu_ui.module

Probably belongs to the menu_ui module