Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295107

Allow ?edit[field_xyz] as query parameter in contextual filter

$
0
0

By providing a query parameter as contextual filter argument, we can already limit the referenceable entitities in an entity reference view, with #1699378: Dynamic Views Arguments via Tokens being only an alternative approach.

In many cases we can use a simple ?key=value query parameter.

When creating a new entity in a dependent dropdown setting with two fields (the entity reference field_city depending on another field_country), we however might want to use the Prepopulate module to prepopulate both field_country and the (dependent) entity reference field_city. We could easily do so, setting both fields at the same time using a single query parameter for field_country that is also caught by the entity reference view and used to restrict the referenceable entities in field_city.

Prepopulate however expects all parameters in the ?edit[field_xyz] form in order to avoid name collisions, and our QueryParameter default argument doesn't support this kind of array structure. Or actually it does. The only problem is the

if ($current_request->query->has($this->options['query_param'])) {

clause, as the flattened edit[field_xyz] parameter is send to ParameterBag->has() which uses array_key_exists() to find the (string) needle in the (array) haystack. Which can't work.

I'm not sure if beyond Prepopulate module there is any use for this kind of array structure in query parameters, and clearly this could be solved by prepopulate module itself, by supplying an altered QueryParameter default argument plugin. On the other hand, why wouldn't we want to support this kind of array structure in Core views, plus the parse_str making this work isn't expensive at all.


Viewing all articles
Browse latest Browse all 295107

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>