Arguments are not passed to the child view from a views field view.

To reproduce, create a child view with a contextual filter (UID from path for example).

Create the views field on the parent view, and then pass the UID argument manually (for example, the number 1).

The argument will be passed correctly and the child view will load the appropriate content belonging to UID 1.

Now use a token (with raw value) to pass an argument to the child view and the child view will not receive the argument.

I have been working on this issue for some time today and believe that the problem lies on line 314 of view.php. Below are lines 312 - 315 of that file:

switch ($token_type) {
      case 'raw_fields':
        $value = $view->field[$id]->getValue($values);
        break;

Using dmp I see that getValue($values) returns empty.

Comments

rich_dawson created an issue. See original summary.

rich_dawson’s picture

Issue summary: View changes
rich_dawson’s picture

Issue summary: View changes
rich_dawson’s picture

Worked some more on this today. Forgot to mention previously that I am using Drupal 8.1.1.

Browsing through Drupal I am unable to find another example of getValue() using a variable (Views Field View passes $values variable to getValue()) in any core modules, or the 20 or so contrib modules I also sifted through. I know that this is how things were done in the Drupal 7 version of this module, but getValue() in 8 is quite different from get_value() in Drupal 7, I wonder if this is really the best way to approach this problem. Did anyone test arguments with raw_field tokens after porting to D8?

As a workaround for other users, simply use fields.uid or fields.nid instead of raw_fields.uid / raw_fields.nid. The problem arises from using the raw_ version of the tokens. Because fields uses the last_render handler, it works as expected. Be sure that you output only the NID or UID numerical value, not any rendered text when passing arguments to a child view.

Also, I notice in testing that variables which are passed with an underscore do not seem to get parsed correctly by the preg_match() on line 344. For example, raw_fields.uid_1 returns an empty array with keys 'type' and 'id' both being null. At this point I am up against a deadline on my project, so I am going to use the field token rather than raw_field as a workaround.

klagler’s picture

Are there any news on this ? I'm having the same issue with my installation, using the latest views_field_view.dev Version and drupal 8.2.5

lissy’s picture

I have exactly the same Issue with Drupal 8.3.0 + views_field_view 8.x-1.0-beta2.
When I test the child view with numbers, it is shown.
When I use token, it not appears.
I tried with raw_field and field, no difference.
I configured the value so, that no div-Containers or classes are in the value for the argument.

hanoii’s picture

Try dev, some of the issues reported here (specifically the one with underscores, should be fixed there)

gg24’s picture

Hi,

I think https://www.drupal.org/node/2873359 issue is related to this only. I have tried reproducing this issue and couldn't do so. I think this is fixed in the latest version.

Tried on Drupal 8.4.x and views_field_view 8.x-1.x version.

Thanks!