diff --git a/assets/js/app/editor/Components/Collection.vue b/assets/js/app/editor/Components/Collection.vue
index 3bbdbbbf..f9ca63f5 100644
--- a/assets/js/app/editor/Components/Collection.vue
+++ b/assets/js/app/editor/Components/Collection.vue
@@ -4,16 +4,19 @@
-
-
+
+
+
+
diff --git a/src/Entity/Field/CollectionField.php b/src/Entity/Field/CollectionField.php
index 4415b821..9c4e0c89 100644
--- a/src/Entity/Field/CollectionField.php
+++ b/src/Entity/Field/CollectionField.php
@@ -54,6 +54,7 @@ class CollectionField extends Field implements FieldInterface
foreach ($fieldDefinitions as $fieldName => $fieldDefinition) {
$templateField = parent::factory($fieldDefinition, '', $fieldName);
+ $templateField->setDefinition($fieldName, $this->getDefinition()->get('fields')[$fieldName]);
$templateField->setName($fieldName);
$result['templates'][$fieldName] = $templateField;
}
diff --git a/templates/_macro/_macro.html.twig b/templates/_macro/_macro.html.twig
index 9b3f0041..7f741c42 100644
--- a/templates/_macro/_macro.html.twig
+++ b/templates/_macro/_macro.html.twig
@@ -44,15 +44,18 @@
{% if item_field.definition.type == 'set' %}
{% set hash = item_field.hash %}
{% else %}
+ {# non-set fields do not have hashes, so we create a 'dummy' hash from the current loop index. #}
{% set hash = loop.index0 %}
{% set collectionItemName = collectionItemName ~ '[' ~ hash ~ ']' %}
{% endif %}
- {% set existing_field %}
+ {% set new_field %}
{% include '@bolt/_partials/fields/' ~ item_field.type ~ '.html.twig' with
{'field': item_field, 'in_collection': true, 'is_first': loop.index0 == 0, 'is_last': loop.index == fields|length, 'name': collectionItemName, 'collection_name': collectionField.name, 'hash': hash } only %}
{% endset %}
- {% set fieldsHtml = fieldsHtml|merge([{'html': existing_field, 'hash': hash, 'label': item_field.definition.label}]) %}
+ {# set the label manually as set in _base.html.twig, to pass to Collection.vue for templates #}
+ {% set label = item_field.definition.label|default(item_field.name|default('unnamed')|ucwords) %}
+ {% set fieldsHtml = fieldsHtml|merge([{'html': new_field, 'hash': hash, 'label': label}]) %}
{% endfor %}
{{ fieldsHtml|json_encode }}
{% endapply %}{% endmacro %}
diff --git a/templates/_partials/fields/_base.html.twig b/templates/_partials/fields/_base.html.twig
index 9edd7cf3..2f3247c1 100644
--- a/templates/_partials/fields/_base.html.twig
+++ b/templates/_partials/fields/_base.html.twig
@@ -97,6 +97,7 @@
{% endblock %}
+{{ postfix|raw }}
{% if in_collection is defined %}
@@ -114,5 +115,5 @@
{{ 'collection.remove_item'|trans }}
{% endif %}
-{{ postfix|raw }}
+
diff --git a/templates/_partials/fields/set.html.twig b/templates/_partials/fields/set.html.twig
index abddb969..72fbdbc5 100644
--- a/templates/_partials/fields/set.html.twig
+++ b/templates/_partials/fields/set.html.twig
@@ -11,6 +11,4 @@
{% set setItemName = setName ~ '[' ~ field.value.hash ~ ']' ~ '[' ~ fieldItem.name ~ ']' %}
{% include '@bolt/_partials/fields/' ~ fieldItem.type ~ '.html.twig' with {'field' : fieldItem, 'name' : setItemName} only %}
{% endfor %}
-
-
{% endblock %}