When saving the configuration for "menu tree of the menu selected by the page" pane Drupal reports a validation error "An illegal choice has been detected. Please contact the site administrator."

Unsetting #options for the element seems to fix this. This is included in the patch.

Members fund testing for the Drupal project. Drupal Association Learn more


richH’s picture

Have exactly the same problem - the patch seems to work though although I'm having some style issues. Will keep an eye on it!

rootwork’s picture

Issue tags: +panels, +Page Manager

Same issue, and the patch fixed it for me. I'm not sure if two positive reviews makes for RTBC -- maybe the module maintainer can review and commit it if it's ready? Without the patch, it's impossible to use this (really useful!) function in any Panels pages.

JesseDP’s picture

Version: 6.x-2.x-dev » 7.x-2.3

This bug still exists in 7.x-2.3

You have to do unset($form['parent_mlid']['#options']); in stead of unset($form['parent']['#options']); as seen in the patch above

jweowu’s picture

Version: 7.x-2.3 » 7.x-2.x-dev
5.28 KB

Disabling option validation by unsetting #options is just masking one instance of the bug (and disabling validation isn't a good idea in any case -- it's always better to insert the value you want into the options, so that it will pass validation, but still protect against modified submissions).

The actual problem here is that the default_value for the parent_mlid form element is being badly generated: instead of containing '_active:0', that value gets the '_active' menu name prepended to it again in menu_block_configure_form(), giving us '_active:_active:0' as the option to validate against, which is why the illegal value error is raised.

This isn't just an issue with the pane (menu_tree content type plugin); it's actually a general problem with the menu_block module. It's just a little less obvious in other circumstances (when the form element isn't hidden) because the mismatched default_value never gets submitted in that case.

I believe this bug was partly caused by the way that the 'parent_mlid' value is 'hijacked' to store a 'menu-name:mlid' string (which was then stored under the name 'parent' in the database). Initially parent_mlid is an integer, but then it ends up as a string.

In order to avoid this complication and resolve the bug, this patch separates those two concepts into distinct 'parent_mlid' (integer) and 'parent' (menu-name:mlid string) values.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

I had to remove and re-add the menu block to the pane, but this worked just fine.

mikl’s picture

I've backported the patch from #4 to Drupal 6.

JohnAlbin’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

The patch looks sensible, but I'm unable to reproduce this error with the latest 7.x-2.x code. When I configure the "menu tree of the menu selected by the page" pane in panels, I dont' receive any errors. I also did a dsm($form) at the end of menu_block_configure_form() and I'm not seeing the _active:_active:0 problem described.

Either the bug no longer exists or I'm doing something "wrong" when trying to reproduce this error.

JohnAlbin’s picture

Title: Pane generates illegal choice error when saving » Pane generates illegal choice error when editing
Status: Postponed (maintainer needs more info) » Needs review

And now I've experienced it. :-p

I didn't get it when I added the pane to the layout, but it did occur when I was editing the pane's configuration.

JohnAlbin’s picture

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