Problem/Motivation

On a content-moderated node that appears in the menu as an automatic child, changing the node title and saving (typically as a draft / pending revision) shows:

You can only remove the menu link in the published version of this content.

Followed by:

Warning: Undefined array key "#parents" in Drupal\Core\Form\FormState->getError() (line 1176 of core/lib/Drupal/Core/Form/FormState.php).
Warning: foreach() argument must be of type array|object, null given in Drupal\Core\Form\FormState->getError() (line 1176 of core/lib/Drupal/Core/Form/FormState.php).

The title is not saved. Introduced in 1.2.0 when the node form started hiding menu_ui's widget for managed children (#29 / the archive fatal).

Steps to reproduce

  1. Enable Menu Autopilot on a parent; publish a matching node so an automatic child exists.
  2. Use content moderation on that node type.
  3. Edit the node, change the title, save as a draft (or any pending revision).

Proposed resolution

Hiding $form['menu'] in #after_build is too late: menu_ui has already treated the missing checkbox as enabled = 0. Restore enabled = 1 (and the existing entity id) on the form state, and do not let menu_ui's submit handler write the managed child. Keep the widget hidden so editors still go to the parent for label and order.

GitHub: https://github.com/Wilkes-Liberty/menu_autopilot/issues/31

Remaining tasks

  • Regression test
  • Fix
  • Release

User interface changes

None. The automatic-child notice on the node form stays.

API changes

None.

Data model changes

None.

Comments

jmcerda created an issue. See original summary.

jmcerda’s picture

Status: Active » Fixed

Fixed in 1.x: https://github.com/Wilkes-Liberty/menu_autopilot/pull/32

Same failure on a subtitle-only save (any field on an automatic child). 1.2.1 will pick this up.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.