Added collection count when adding new rows to a collection. #528

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+4 −1
Diff settings

Always

Just for now

View
@@ -154,7 +154,9 @@ var Admin = {
var container = jQuery(this).closest('[data-prototype]');
var proto = container.attr('data-prototype');
- proto = proto.replace(/\$\$name\$\$/g, '');
+ var count = container.attr('data-count');
+ proto = proto.replace(/\$\$name\$\$/g, count);
+ container.attr('data-count',++count);
jQuery(proto).insertBefore(jQuery(this).parent());
});
@@ -125,6 +125,7 @@ file that was distributed with this source code.
{% if prototype is defined %}
{% set child = prototype %}
{% set attr = attr|merge({'data-prototype': block('collection_widget_row') }) %}
+ {% set attr = attr|merge({'data-count': form | length }) %}
{% endif %}
<div {{ block('widget_container_attributes') }}>
{{ form_errors(form) }}