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
- Enable Menu Autopilot on a parent; publish a matching node so an automatic child exists.
- Use content moderation on that node type.
- 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
Comment #2
jmcerdaFixed 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.