# Repeater field funkyness

**URL:** <https://community.hubspot.com/t/repeater-field-funkyness/54836>\
**Category:** CMS Development\
**Created:** [April 12, 2022, 9:32am UTC](https://community.hubspot.com/t/repeater-field-funkyness/54836 "2022-04-12T09:32:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TTimes](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ttimes/32/193891_2.png) [@TTimes](https://community.hubspot.com/u/TTimes)\
**Post date:** [April 12, 2022, 9:32am UTC](https://community.hubspot.com/t/repeater-field-funkyness/54836/1 "2022-04-12T09:32:47Z")

</div>

Alright…

I have a module where the editor can add a checkmark list and a number of buttons to their liking. Both groups are repeaters:

```lia-code-sample
{# List items, if any added #}
 {% if module.text.list_item %}
 <ul class="image-text__checklist checklist"> 
 {% for item in module.text.list_item %}
 <li>
 {# Icon #}
 <div class="image-text __checklist-checkmark checklist__ checkmark">
 <svg class="image-text __checklist-icon checklist__ icon checklist__icon--checkmark">
 <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#checkmark"></use>
 </svg>
 </div>
 {# Text #}
 <span>{{ item.value }}</span>
 </li>
 {% endfor %}
 </ul>
 {% endif %}
 {# Buttons, if any added #}
 {% if module.text.buttons %}
 <div class="image-text__buttons">
 {# Button loop #} 
 {% for button in module.text.buttons %} 
 <a href="{{ button.button.url.href }}" title="{{ button.title }}" class="btn{% if loop.index > 1 %} btn--ghost{% else %} btn--default{% endif %}{% if button.icon %} btn--icon{% endif %}{% if button.icon_reverse %} btn--icon-reverse{% endif %}{% if button.video_link %} js-btn--video btn--video{% endif %}" {% if button.video != "" %}data-video-url="{{ button.video }}"{% endif %}>
 {% if button.icon.src != '' %}
 <img src="{{ button.icon.src }}" alt="{{ button.icon.alt }}"> 
 {% endif %}
 <span>{{ button.title }}</span>
 </a>
 {% endfor %}
 </div>
 {% endif %}

```

This is the editor look:

 ![TTimes_0-1649755737388.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/e/7/e76a50e82f2754820b17c6a8b7df37c616dbadfa.png)

And this is the output:

 ![TTimes_1-1649755767799.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/4/44a86e22975bf2ebfb0b9911895034de3f988230.png)

Adding two checkmark items adds 4 empty buttons in the UI 😅  
What’s going on?  
I can fix it by adding a button in the UI and removing it again. But still, the two loops are hardly related, so i’m quite interested to see if anyone can figure out what’s happening - if it’s not a bug 🙂

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [April 12, 2022, 10:12am UTC](https://community.hubspot.com/t/repeater-field-funkyness/54836/2 "2022-04-12T10:12:36Z")

</div>

Hmm, that is indeed odd. When doing an if statement checking for a repeater field, I would check whether it’s iterable, rather than whether it exists e.g.

```lia-code-sample
{% if module.text.buttons|length > 0 %}
..
{% endif %}

{# or #}

{% if module.text.buttons is iterable %}
..
{% endif %}

```

---

<div class="post-metadata">

**Author:** ![TTimes](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ttimes/32/193891_2.png) [@TTimes](https://community.hubspot.com/u/TTimes)\
**Post date:** [April 12, 2022, 10:29am UTC](https://community.hubspot.com/t/repeater-field-funkyness/54836/3 "2022-04-12T10:29:54Z")

</div>

I learn something new every day with this wonderful platform. Thanks!  
“is iterable” did indeed solve the issue. Don’t know if checking for existense is considered “wrong” in HubL, but if not, i’d say something fishy is going on.

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [April 12, 2022, 2:20pm UTC](https://community.hubspot.com/t/repeater-field-funkyness/54836/4 "2022-04-12T14:20:12Z")

</div>

I think the issue is that on the server the dict/object “module.text.buttons” exists, created by it being a repeater field, but is empty. What really matters is whether that object contains anything

---

<div class="post-metadata">

**Author:** ![TTimes](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ttimes/32/193891_2.png) [@TTimes](https://community.hubspot.com/u/TTimes)\
**Post date:** [April 12, 2022, 4:27pm UTC](https://community.hubspot.com/t/repeater-field-funkyness/54836/5 "2022-04-12T16:27:21Z")

</div>

Makes sense. Thanks for taking the time to elaborate. Much appreciated

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [April 12, 2022, 4:38pm UTC](https://community.hubspot.com/t/repeater-field-funkyness/54836/6 "2022-04-12T16:38:01Z")

</div>

Thnkas for taking a look, @piersg 🙌
