- πΊπΈUnited States emanaton
I'm having this issue as well, but have a solution which I'm pasting here for posterity and to help the next coder who's still having this issues.
My fix is to add the following as an additional submit function on the Views Exposed Form (i.e. adding this function to the `$form['#submit']` array within a `hook_form_views_exposed_form_alter` implementation):
/** * Set the default sort from the BEF filter in the $form_state. * * This is being done so that the view's pagination URLs have a default value * set. Without this, click on pagination before executing a sort results in * an error message being displayed: "An illegal choice has been detected. * Please contact the site administrator." * * @param $form * @param \Drupal\Core\Form\FormStateInterface $form_state * * @return void */ function my_theme_fix_bef_filters(&$form, \Drupal\Core\Form\FormStateInterface $form_state) { if ( // if there's "sort_by" then the user hasn't explicitly set the sort order. !$form_state->getValue('sort_by') // check that the better exposed filter combined sort option has been set... && !empty($form['#info']['sort-sort_bef_combine']['value']) // ... and get whatever key it's configured under for ease of reference... && ($combined_sort_key = $form['#info']['sort-sort_bef_combine']['value']) // ... and check if the sort options are exposed to the user... && !empty($form[$combined_sort_key]['#options']) // ... and that there's a usable key set as the first sort option. && !!($sort_value = array_key_first($form[$combined_sort_key]['#options'])) ) { $form_state->setValue($combined_sort_key, $sort_value); } }
- Status changed to Needs work
over 1 year ago 8:45am 3 August 2023 - π¬π·Greece vensires
I am reopening this as it's still a case for version 6 of the module and still a fix is needed.
In my case, I have three different exposed sorting options: created, price and title. The first time I am changing the sorting, it changes and no error is displayed. The second time I change the sorting, the message An illegal choice has been detected. Please contact the site administrator. appears though the sorting still works.
- Status changed to Closed: won't fix
over 1 year ago 10:26pm 3 August 2023 - π¬π·Greece vensires
I reverted to the last status of the ticket before my comment because the issue I faced was different it seems - at least in 6.x.
I had two different views on the page: one was my main content's view and the other was a search view. Both were using BEF - resulting in both using the
sort_bef_combine
key. When changing the sorted property of the main content's view, the other view was also catching the same value and was trying to set it as default but obviously failed validation.The solution in my case was thus patching with the last patch from π Enable changing sort_bef_combine parameter key RTBC which - thank God - also applies to 6.x and set a different machine name for the element containing the combined keys. As a result, we now have two different fields and no ambiguation exists.
- Merge request !42Draft: Issue #3047454: An illegal choice has been detected - GET requests with BEF combined β (Closed) created by vensires
- Status changed to Needs review
about 1 year ago 9:42am 22 September 2023 - π³π±Netherlands arantxio Dordrecht
So we have noticed that this issue still existed on our site and created a patch based on the code from @scott_euser.
It should apply to both 5.x and 6.x
- Status changed to Needs work
about 1 year ago 12:38pm 22 September 2023 - π³π±Netherlands arantxio Dordrecht
So apparently it was due to old referenced links. After the update the code has changed from blank spaces to underscores, when links are referenced they still had the blank space in them and now the better exposed filters doesn't handle the old way.
It would be nice if we could handle this so people upgrading don't have to update all their content.
- πΊπΈUnited States smustgrave
Curious if #11 solve the problem for anyone?
- Status changed to Postponed: needs info
about 3 hours ago 11:37pm 18 December 2024 - πΊπΈUnited States smustgrave
So I tried replicating this but not getting an error, could some one verify if it still happens on 7.0.x?