A viewsreference field with no argument supplied is not working when referencing a view block containing a contextual filter that sets 'Provide default value' of 'Content ID from URL'.

In this case, an empty string argument is passed to views_embed_view() in ViewsReferenceFieldFormatter::viewElements() and views is not applying default value handling. Apparently views_embed_view() needs a NULL argument to recognize the filter value is unavailable.

One workaround is to coerce empty string arguments to NULL in ViewsReferenceItem::setValue().

Comments

keithm created an issue. See original summary.

keithm’s picture

Title: Empty arguments break views contextual filter default value handling » Empty viewsreference argument breaks contextual filter default value handling
Issue summary: View changes
keithm’s picture

StatusFileSize
new745 bytes

Rerolled patch to detect missing argument key.

NewZeal’s picture

Keith,

Can you download the latest dev code, check your change is in the code, test and report back so we can go beta: https://www.drupal.org/node/2846411

Thanks

Kent

keithm’s picture

Kent,

Confirming patch #3 is included in commit c71890f07e8632ce7fe6984b2961782e426d85bd, and tested processing of empty viewsreference argument works as designed.

For future reference, would you please give credit to issue contributors in your commit messages? The template is given below in 'Credit & commiting'.

Thanks.

Keith

joekers’s picture

I can confirm this is now working - thanks for reporting the issue and providing the patch.

NewZeal’s picture

joekers’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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