Hi guys!
I’m working on a landing page and i just made a repeater field with this code i found on the hubspot docs page.
{% set my_options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] %}
{% choice "repeats" label="Number of modules to print", value="1", choices="{{ my_options }}", export_to_template_context=True %}
{% for options in my_options %}
{% if loop.index <= widget_data.repeats.value %}
{% linked_image "repeated_image" label="Repeated image", alt="Photo of Brian Halligan", src="//cdn2.hubspot.net/hub/53/file-733888619-jpg/assets/hubspot.com/about/management/brian-home.jpg", unique_in_loop=True %}
{% text "repeated_caption" label="Repeated caption", value="Insert caption here", unique_in_loop=True %}
{% endif %}
{% endfor %}
I have an issue with the labels i each iteration of the foor loop, it creates the fields correctly, but the labels are the same for every iteration, i tried to put the index of the loop inside the label of the custom module like this:
{% text "repeated_caption" label="Repeated caption-{{loop.index}}", value="Insert caption here", unique_in_loop=True %}
But when i go to edit the page it doesn’t work, is there anyway i can identify every label differently?
Thanks!
1. unique_in_loop=true - makes the system name for the module unique
2. widget_attribute label - I broke the label loose using block syntax and set the loop index at the end to make it unique.
You should know that the ordering of modules using this method is utter chaos on the editor page. Instead of it display:
text 1
image 1
text 2
image 2
text 3
image 3
it will be more like:
image 3
text 1
text 2
image 1
text 3
image 2
It’s a bit of a mess. Makes for some pretty decent customization though.
is it possible that you are updating the wrong template?
try creating a new landing page from the right template. I’ve confirmed the code works on my end, unless there is a caching issue or you are using the wrong template, I’m not sure why it isn’t working.
For some reason the same code doesn’t work with custom modules inserted into the template, is there a way I can edit the label of the custom_widget module?
Thanks a lot!