Hi,
I've noticed that DynamicForm.valuesHaveChanged() always returns true then i call saveData().
Problem is that I have a field in datasource which is only generated by server side. `added_at` datetime.
I've declared that field in frontend DataSource as
Code:
{
name: "addedAt",
type: "datetime",
disabled: true,
useTextField: true,
shouldSaveValue: false
},
Problem is in DynamicForm._saveDataReply : function (request, response, data)
Code:
var compareVal = submittedValues[i] === undef ? this._oldValues[i] : submittedValues[i];
var field = this.getField(i); // <- (1) HERE WE COMPARING FIELD VALUES WITH SERVER RETURNED VALUE
// check whether the form item has changed since submission
if (this.fieldValuesAreEqual(field, currentValues[i], compareVal)) {
// if not, check whether the server changed the submitted value to
// something else
if (!this.fieldValuesAreEqual(field, compareVal, data[i])) {
currentValues[i] = data[i];
hasChanges = true;
}
} else {
// value in the form has changed since being submitted
rememberValues = false; // <-- (2) HERE, REMEMBER VALUES ARE SET TO FALSE
}
You can see from code that (1) is comparing current dynamic field value with server response, and do not check is this field is even disabled or shouldSaveValue: false;
so then server returns a response with `added_at` value, this logic acts like dynamic form `added_at` is changed and (2) logic applies, so after save success, rememberValues() is not called, and I always getting
DynamicForm.valuesHaveChanged() true. And all field aren't remembered.
Please add into (1) a bypass if field has shouldSaveValue:false or disabled:true, maybe should bypass if field do not exists on dynamicform at all.
Actually it's deeper problem, because all fields which was edited is now treated like as not persisted, and
DynamicForm.valuesHaveChanged(true) returns all edited fields which was saved.
Suggestion:
I suggest not to call rememberValues() for all fields at once, but use one by one field values to set to _oldValues[] array if it was correctly persisted.
Tested on: v10.0p_2015-07-25/LGPL Deployment
But I think all versions are affected by this.
Thanks.