0

I have a Paragraph nested in another Paragraph as per attached screenshot in Drupal 9. I want to write a conditional for my_repeater_2 that's based off the value of the my_dropdown field in my_repeater_1.

The keys|values in my_dropdown are:

1|25:75
2|50:50

I have a template field--paragraph--my-repeater-1.html.twig with the following and it outputs 1 or 2 depending on the dropdown selection.

 {% for item in items %}
        {{ item.content }}
    {% endfor %}

I also have a template paragraph--my_fields.html.twig with:

   {%
      set classes = [
        'paragraph',
        'paragraph--type--' ~ paragraph.bundle|clean_class,
        view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
        not paragraph.isPublished() ? 'paragraph--unpublished'
      ]
    %}
{% block paragraph %} 
  {% block content %} 
      {% if content.my_dropdown.0 == "1" %}
         DO X
      {% endif %}
      {% if content.my_dropdown.0 == "2" %}
         DO Y
     {% endif %}
   {% endblock %}
{% endblock paragraph %}

How do I retrieve the value from the my_dropdown field in my_repeater_1, as content.my_dropdown.0 doesn't work, so my IF conditional can process. I've tried every variation at https://drupal.stackexchange.com/questions/274359/get-pre-processed-data-from-nested-paragraphs. Must be something easy?

enter image description here

zcoop98
  • 2,590
  • 1
  • 18
  • 31
Jack L
  • 21
  • 3

0 Answers0