diff --git a/static/plugin_dbui/src/appform.js b/static/plugin_dbui/src/appform.js index 335082e336a6b55fd3c0c0d9d9e4fd80d7d263ee..8b8975b74ea7ae0917ed03d2c74e1f7e100f98c4 100644 --- a/static/plugin_dbui/src/appform.js +++ b/static/plugin_dbui/src/appform.js @@ -158,6 +158,22 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { } }, + /** + * Private method to hardreset the form + * The reset method resets the field value to the originally loaded. + * The hardreset erases the originally loaded values and reset the form. + * Hardreset is required to clean form in sequence like update, create,... + */ + hardReset: function () { + var form = this.getForm(); + + form.items.each(function (field) { + field.originalValue = ""; + }); + + form.reset(); + }, + /** * Private handler to process store exception * the scope of this function is App.form.FormPanel @@ -199,7 +215,9 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { */ setAction: function (action, record) { - var form = this.getForm(); + var form = this.getForm(), + table, + tableId; this.buttonReset.show(); this.buttonAction.show(); @@ -209,11 +227,13 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { this.currentAction = action; this.currentRecord = record; + this.hardReset(); + switch (action) { case 'create': + this.buttonAction.setText(this.textCreate); - form.reset(); break; case 'destroy': @@ -223,8 +243,9 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { case 'duplicate': this.buttonAction.setText(this.textDuplicate); - form.reset(); - delete record.id; + table = App.getTableName(this.store); + tableId = App.encodeField(table, 'id'); + delete record.data[tableId]; form.loadRecord(record); break;