0

I am attempting to embed a view in a webform whose contextual filter value is set based on a user selection. I have created a view of nodes with a contextual filter, and a webform with a select element and a computed twig element. In the computed twig element I have the following code:

{% set gsheatcheck = (data.gs_aut_heat_rejection_rating) %}
{% if gsheatcheck == '1' %}
{{ drupal_view('aps_heat_rejection', 'page_1', 'TSER=1--20') }}
{% elseif gsheatcheck == '2' %}
{{ drupal_view('aps_heat_rejection', 'page_1', 'TSER=21--40') }}
{% endif %}

My problem is if gsheatcheck=1 the view displays properly (showing nodes whose TSER value is 1-20), but if gsheatcheck=2 the view displays nodes whose TSER value is 1-40 (seemingly ignoring the middle two range boundaries).

I thought this may be a caching issue, but turning off caching for the view does not produce a different result.

This is what Devel shows for Render:

concerns:
  '#type': webform_wizard_page
  '#title': Concerns
  gs_aut_heat_rejection_rating:
    '#type': webform_rating
    '#title': 'heat rejection rating'
    '#description': 'Is heat rejection a concern for you?'
    '#default_value': 0
  test_view_1:
    '#type': webform_computed_twig
    '#title': test_view_1
    '#template': |
      {% set gsheatcheck = (data.gs_aut_heat_rejection_rating) %}
      {{ gsheatcheck }}
      {% if gsheatcheck == '1' %}
      {{ drupal_view('aps_heat_rejection', 'page_1', 'TSER=1--20') }}
      {% elseif gsheatcheck == '2' %}
      {{ drupal_view('aps_heat_rejection', 'page_1', 'TSER=21--40') }}
      {% endif %}
    '#ajax': true

For reference I'm using the following versions: Drupal (8.8.4), Webform (8.x-5.9), Twig Tweak (8.x-2.5) and Contextual Range Filter (8.x-1.0-rc1).

I'm probably going about this the wrong way, so any insight will be greatly appreciated. TIA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.