The submitted value [value] in the [name] element is not allowed.

Created on 8 May 2024, 8 months ago

Problem/Motivation

I have been trying to get up and running with views + facets but it seems like selecting any option from a facet gives me the following error:

The submitted value [value] in the [name] element is not allowed.

Steps to reproduce

  • Download facets 3.0-dev
  • Enable Facets & Facets exposed filters (Experimental)
  • Configure Facet source to be "Views exposed filters"
  • Add facet to the facet source
  • On your view expose the facet via the "Facet" field
  • Configure the field widget via BEF (in my case I am using Select2)
  • View your facet and try to select an option
  • Error is thrown

Proposed resolution

Looking at the issue the problem seems to be that the "options" key is empty at the time the data is sent, I'm not sure why this is, I have tried multiple widgets but they all give different errors.

Remaining tasks

To fix the problem :D

---

Does anyone have a working views + facets + ajax using v 3.0 ?

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom 3li U.K. πŸ‡¬πŸ‡§

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @3li
  • Same problem here. Using std checkboxes it's working but not with Select2.

  • πŸ‡¬πŸ‡§United Kingdom 3li U.K. πŸ‡¬πŸ‡§
  • πŸ‡¬πŸ‡§United Kingdom 3li U.K. πŸ‡¬πŸ‡§

    Think I found the problem.
    We should be running an extra process facets_exposed_filter_remove_validation (facets/modules/facets_exposed_filters/src/Plugin/views/FacetsViewsPluginTrait.php) which is meant to unset($element["#needs_validation"]);

    However for some reason when using select2 nothing gets created and thus this process does not get attached or run, meaning that validation is still enabled.

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Bumping this to major as it affects this basic functionality from working as expected.

  • πŸ‡§πŸ‡ͺBelgium StryKaizer Belgium

    Core Views renders its "exposed form" before it fires the query.

    Because how facets work, we only know the values after the query has been executed.
    Thats why we re-render the exposed form again a second time.

    That's why, if you are debugging, the first time you'll see an empty #options list, which is re-rendered the second time.

    I dont have time to debug the select2 implementation, but this info could help somebody debugging it ;)

  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    I have the same issue when using only facets + views + exposing sorting options in the view.
    Not using select2, nor Facets exposed filters (Experimental).
    The results are sorted as expected, just the warning is there.

  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    My sort fields were called "name" and "changed".
    Debugging this I found that the valid values were "title", "z_date" and "relevance", but not sure where this keys are coming from.
    Might be a different issue than the one you are having.

  • πŸ‡§πŸ‡·Brazil edmargomes

    If I use select2 in BEF then I have the same problem.

    But, if I keep the default value widget or checkbox, worked

    Then, I made a test, I changed select to select2 in FacetFilter line 174

    $form['value'] = [
          '#type' => 'select2',
          '#options' => $this->buildOptions($facet->getResults(), $facet),
          '#multiple' => $this->options["expose"]["multiple"],
          '#process' => array_merge($select_element["#process"], ['facets_exposed_filters_remove_validation']),
        ];
    

    This worked too

    I tried form alter and add this:

    $form['city']['#type'] = 'select2';
    

    But show the same problem, only worked in valueForm on FacetFilter

    I am searching for Drupal away solution yet

  • πŸ‡§πŸ‡·Brazil edmargomes

    I fixed my problem with this:

    I created a form alter and added

    if ($form_id == 'views_exposed_form' && $form['#id'] == 'views-exposed-form-faros-companies-search-search-companies-block') {
        if (isset($form['city']['#process']))
          $form['city']['#process'] = array_merge($form['city']["#process"], ['facets_exposed_filters_remove_validation']);
      }
    
  • πŸ‡§πŸ‡ͺBelgium StryKaizer Belgium

    @edmargomes can you please let me know which exact facets3 version you are using?

    Since beta3, I dont think adding this function should matter anymore, and I was thinking about removing that part entirely.

  • πŸ‡ΊπŸ‡ΈUnited States ethomas08 SF Bay Area

    I am experiencing this bug and just upgraded to the beta4 release for the facets module. Using the select2 widget setting with BEF.

  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    In my case, described in #7 and #8, I discovered my issue is that I had two different exposed blocks with (different) exposed sorting options in the same page. As both use "sort_by" and "sort_order", one of them is gonna parse wrong values and throw that error.

    I've created ✨ Views exposed sort identifiers are not configurable when also exposed Active in core that fixed it for me. Also ✨ Allow exposed form to preserve URL query parameters Postponed: needs info to be able to use this in BEF. So at the end it wasn't facets related.

Production build 0.71.5 2024