The fix has side effects in combo boxes using forceSelection true.
A piece of code is activated making impossible to revert back to the last valid value after write invalid data in the field TWICE.... the first time it works.
Below an override of combobox that fixes the problem but I don't know the side effects so far:
Code:
/**
*
* Normally when entering a value into a form and the value is considered invalid according to Ext.form.field.Base.isValid() this method will not be called.
* This means that the model backing the form will never be populated with an invalid value. This strategy is by design see
*
* https://www.sencha.com/forum/showthr...bind-value-bug
* https://www.sencha.com/forum/showthr...ith-validation
*
* but seems to be controversial and it is unclear as to how validators associated with the model (model validation) would ever work as once a field
* was made invalid how would it be made valid again as the model needs to be populated in order for the model validators to revalidate the
* now valid value. TODO - should follow up on this.
*
* To work around this the Ext.form.field.Base.publishValue() method has been overriden and the model is populated even if the field is invalid, this is particularly
* important for UniWorks as the calculation of what is valid is done on the server so any value whether valid or invalid needs to be set on the model in order
* to send back to the server.
*
* However the override to the Ext.form.field.Base.publishValue() method has introduced an side effect when clearing a form text field with forceSelection=true.
* The first time the field is cleared, upon onBlur() the current value is reverted to the previous value (lastSelectedRecords) and the previous value (lastSelectedRecords)
* is set to null. The second time the field is cleared the current value is reverted to the previous value (lastSelectedRecords) which was previously set to null which
* is not the previous 'valid' value.
*
*
* @param {type} value
* @returns {Array.setValue.me|ComboBoxAnonym$0.setValue}
*/
setValue: function(value) {
var me = this,
bind, valueBind;
// Here we check if the setValue is being called by bind getting synced
// if this is the case while the field has focus. If this is the case, we
// don't want to change the field value.
if (me.hasFocus) {
bind = me.getBind();
valueBind = bind && bind.value;
if (valueBind && valueBind.syncing) {
if ((Ext.isEmpty(value) && Ext.isEmpty(me.value)) || value === me.value) {
return me;
} else if (Ext.isArray(value) && Ext.isArray(me.value) && Ext.Array.equals(value, me.value)) {
return me;
}
}
} /*
Commented out to fix issue described above
else {
// This is the value used to forceSelection in assertValue if
// an invalid value is left in the field at completeEdit. Must be cleared so
// that the next usage of the field is not affected, but only if we are setting
// a new value.
me.lastSelectedRecords = null;
}*/
if (value != null) {
me.doSetValue(value);
}
// Clearing is a special, simpler case.
else {
me.suspendEvent('select');
me.valueCollection.beginUpdate();
me.pickerSelectionModel.deselectAll();
me.valueCollection.endUpdate();
me.resumeEvent('select');
}
return me;
}