|
@@ -158,12 +158,12 @@ var Admin = {
|
|
|
var proto = container.attr('data-prototype');
|
|
|
// Set field id
|
|
|
var idRegexp = new RegExp(container.attr('id')+'___name__','g');
|
|
|
- proto = proto.replace(idRegexp, container.attr('id')+'_'+container.children().length);
|
|
|
+ proto = proto.replace(idRegexp, container.attr('id')+'_'+(container.children().length - 1));
|
|
|
|
|
|
// Set field name
|
|
|
var parts = container.attr('id').split('_');
|
|
|
var nameRegexp = new RegExp(parts[parts.length-1]+'\\]\\[__name__','g');
|
|
|
- proto = proto.replace(nameRegexp, parts[parts.length-1]+']['+container.children().length);
|
|
|
+ proto = proto.replace(nameRegexp, parts[parts.length-1]+']['+(container.children().length - 1));
|
|
|
jQuery(proto).insertBefore(jQuery(this).parent());
|
|
|
|
|
|
jQuery(this).trigger('sonata-collection-item-added');
|