Fix #304, saving array fields

This commit is contained in:
Flavio Copes
2015-11-27 19:28:19 +01:00
parent b7e3978af0
commit 4f29263377
2 changed files with 14 additions and 2 deletions

View File

@@ -98,12 +98,20 @@
ArrayField.prototype.remove = function(event) { ArrayField.prototype.remove = function(event) {
var row = $(event.target).closest('[data-grav-array-type="row"]'); var row = $(event.target).closest('[data-grav-array-type="row"]');
var lastItem = false;
if (row.siblings().length == 0) { if (row.siblings().length == 0) {
//on the last item we just clear its values //on the last item we just clear its values
row.find('input').val(''); lastItem = true;
return; this.add(event);
} }
row.remove(); row.remove();
if (lastItem == true) {
this.refreshAll();
}
if (this.isValueOnly()) { if (this.isValueOnly()) {
this.refreshAll(); this.refreshAll();
} }

View File

@@ -38,6 +38,10 @@
</div> </div>
{% else %} {% else %}
{% if field.value_only != true %} {% if field.value_only != true %}
{% if key == '0' and text == '' %}
{% set key = '' %}
{% endif %}
<input data-grav-array-type="key" type="text" value="{{ key }}" placeholder="{{ field.placeholder_key|e|tu }}" /> <input data-grav-array-type="key" type="text" value="{{ key }}" placeholder="{{ field.placeholder_key|e|tu }}" />
{% endif %} {% endif %}