Problem/Motivation
When advanced search is set to display on the search results page, if you do not select at least one content type and at least one taxonomy vocabulary, then submitting either the basic or advanced search form on that page will fail with the error: "An illegal choice has been detected. Please contact the site administrator." Watchdog reports this error as "Illegal choice in Only in the category(s) element." (in the case of no taxonomy vocabulary)
Looking in the HTML, I can see a hidden form element, like: <input id="edit-category" type="hidden" value="" name="category">. It seems that the form validation is taking issue with the empty value in this form input. If I use Firebug to delete the hidden input element prior to form submission, then the form validates just fine and returns my search results as expected.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | hidden-input-bug-1856104-1.patch | 1.38 KB | jstoller |
Comments
Comment #1
jstollerThe attached patch changes custom_search_form_alter(), so if either
$form['advanced']['category']['#options'], or$form['advanced']['type']['#options']are empty, the corresponding form elements are unset, rather than changed to hidden. This prevents the empty input elements from rendering, allowing the form to pass validation.Comment #2
jdanthinne commentedThanks. Just pushed the patch to DEV.