Problem/Motivation

When I try to use country field in views as a filter it throws an exception

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">InvalidArgumentException</em>: The configuration property display.default.display_options.filters.field_country_value.value.AL doesn&#039;t exist. in <em class="placeholder">Drupal\Core\Config\Schema\ArrayElement-&gt;get()</em> (line <em class="placeholder">76</em> of <em class="placeholder">core/lib/Drupal/Core/Config/Schema/ArrayElement.php</em>).

How to reproduce

  1. Create a view
  2. Add country_field as a filter
  3. Select Dropdown widget
  4. Select any country
  5. Save the view

Comments

LOBsTerr created an issue. See original summary.

nkoporec’s picture

Priority: Normal » Major

Hi, same issue for me, running Drupal 8.5...it seems like the filter is not working at all, even if you select autocomplete, the error is gone but it still shows all records(no filter applied)...I think we need to create a patch to completely rewrite query function(currently query only runs if you select autocomplete).

nkoporec’s picture

Assigned: Unassigned » nkoporec

working on a patch.

nkoporec’s picture

Status: Active » Needs review
StatusFileSize
new2.94 KB

Created a patch, rewrote the query function, so both(autocomplete and dropdown) filter is working.When the patch is applied the module must be reinstalled(to load a new view schema).

nkoporec’s picture

Assigned: nkoporec » Unassigned
icurk’s picture

Status: Needs review » Needs work

Patch works great. But I would add an update hook, which will update the configuration schema. This will update configuration items for existing users of the module who already had it installed before the changes.

dakala’s picture

Thanks for reporting this and taking it on. I'll take a look at the patch today or tomorrow. Once again, thanks.

alesbencina’s picture

Hello, I have tested the patch and it's working on Drupal 8.4 version.

nkoporec’s picture

Status: Needs work » Needs review
StatusFileSize
new3.73 KB
new518 bytes

Created a patch with fixed issues that @icurk raised.

riddhi.addweb’s picture

StatusFileSize
new82.49 KB

@nkoporec, Thanks for providing the patch, But after applying the patch. It still throws the same error to me can you please provide the new patch or else guide me if i'm wrong.

nkoporec’s picture

@riddhi.addweb hmm...maybe try running Cron manually?

lobsterr’s picture

@nkoropec Thank you for your patch
I carefully checked your patch and found some issues. I'm not sure it is a bug in views or in country module. I will assume it is in the country module, because it works with other modules in the views for me.

1) Widget Autocomplete
it doesn't apply any filters and it doesn't save selected countries. It happens for any types of filters

2) Widget Dropdown
It works for any kind of filters, but in the dropdown we have "Select all" value, which I think should not be there.
It doesn't allow us to select all values, because it adds filter like this

WHERE ((node__field_country.field_country_value = 'all'))

and user interface it displayed as "Unknown"

nkoporec’s picture

Hi @LOBsTerr, here is a new patch which fixes issues that you raised.The select all remains(but it's working now) since it can't be removed.Please reviewed it.

lobsterr’s picture

@nkoropec - Thank you for your contribution. I have tested it.

The Dropdown widget works ok now, but Autocomplete widget doesn't show in the UI selected countries

alesbencina’s picture

Hi, @LOBsTerr I cannot reproduce the problem you are mentioning. Can you please give us more information about the issue, please?

lobsterr’s picture

Steps to reproduce
1) Set Autocomplete widget
2) Find any country, for example France
3) In the "Filter Criteria" section I don't see selected country.

Expected behavior, I should see (= France)

If we use Dropdown widget and select, for example France country. I see the select countries.

I hope it will help.

nkoporec’s picture

Thanks for reviewing my patch! Yeah, this is a small visual issue, which can be confusing(otherwise the filter works as expected) ... The issue exists because we extend ManyToOne which has the select type per default and if we select autocomplete we override the form type and set it to textfield, error appears since views are expecting select with the #options parameter, but it gets textfield with no #options(it's empty that's why no (=) is shown).We could extend StringFilter instead of ManyToOne which will work for autocomplete but than we got a similar issue with dropdown...

hkirsman’s picture

Note that this patch applies only for dev branch.

hkirsman’s picture

And sort of trivial fix should be made. If you go to update.php and see the list of updates then for this module it says: "Implements hook_update_N()." while it should say something like "Update the configuration schema". Took that from your comments, name it better :)

leksat’s picture

I've got "The configuration property doesn't exist" error recently during an update of Drupal core from 8.1 to 8.3.

I tried to
- update the country module to the latest dev version
- use the patches from this issue
Nothing helped.

Here is the fix that I have used: https://github.com/AmazeeLabs/country/commit/ff5eb45a3a81e377cc55dc39c20...
It works for me, but I was in a great hurry (SA-CORE-2018-002 ;P), so better if someone else can test it as well.

dakala’s picture

I've now had a chance to check this bug. After applying the patch here - https://www.drupal.org/project/country/issues/2760243 and https://github.com/AmazeeLabs/country/commit/ff5eb45a3a81e377cc55dc39c20... (and a hook_update) seemed to have fixed the InvalidArgumentException and both dropdown and autocomplete widget work.

Changes are in the updated dev branch. Could we have some confirmation please? Thanks for the good work!

  • dakala committed 6cd37b1 on 8.x-1.x authored by nkoporec
    Issue #2952326 by nkoporec, riddhi.addweb: Impossible to use country...
dakala’s picture

@nkoporec, I've applied the rest of your patch. Filtering works fine and it seems to have partially resolved https://www.drupal.org/project/country/issues/2918968. Briefly, if I select "is all of" filter operator and say I have a node with Panama and Croatia, and another node with Croatia and I filter by "Panama and Croatia" I expect it to return the first one. However, it returns both of them.

Anyways thanks for the patch!

dakala’s picture

Status: Needs review » Reviewed & tested by the community
dakala’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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