Skip to content

Commit dce5578

Browse files
committed
Fix: Field valid states are not considered on save
1 parent 1409b99 commit dce5578

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

www/comps/form.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ let MyForm = {
345345
badLoad:false, // attempted record load with no return (can happen if access is lost during save)
346346
badSave:false, // attempted save (data SET) with invalid fields, also updates data fields
347347
blockInputs:false, // disable all user inputs (used by frontend functions)
348+
firstLoad:true, // form was not used before
348349
lastFormId:'', // when routing occurs: if ID is the same, no need to rebuild form
349350
loading:false, // form is currently loading, informs sub components when form is ready
350351
message:null, // form message
@@ -815,12 +816,17 @@ let MyForm = {
815816
// rebuild form if ID changed
816817
if(this.lastFormId !== this.form.id) {
817818
this.$store.commit('pageTitle',this.title);
818-
this.message = null;
819-
this.showLog = false;
820-
this.titleOverwrite = null;
821-
this.lastFormId = this.form.id;
822-
this.fieldIdsInvalid = [];
823-
this.fieldIdsTouched = [];
819+
this.message = null;
820+
this.showLog = false;
821+
this.titleOverwrite = null;
822+
this.lastFormId = this.form.id;
823+
824+
if(!this.firstLoad) {
825+
// on first load, field states do not need to be reset
826+
// addresses issue in which field valid states are set before reset() is executed
827+
this.fieldIdsInvalid = [];
828+
this.fieldIdsTouched = [];
829+
}
824830

825831
// set preset record to open, if defined
826832
if(this.form.presetIdOpen !== null && this.relationId !== null) {
@@ -833,6 +839,7 @@ let MyForm = {
833839

834840
// reset form behaviour and load record
835841
this.blockInputs = false;
842+
this.firstLoad = false;
836843
this.fieldIdMapOverwrite = this.getFieldOverwritesDefault();
837844
this.timerClearAll();
838845
this.closePopUp();
@@ -982,7 +989,7 @@ let MyForm = {
982989
this.fieldIdsTouched.push(fieldId);
983990
},
984991
fieldSetValid(state,fieldId) {
985-
let pos = this.fieldIdsInvalid.indexOf(fieldId);
992+
const pos = this.fieldIdsInvalid.indexOf(fieldId);
986993
if(state && pos !== -1) return this.fieldIdsInvalid.splice(pos,1);
987994
if(!state && pos === -1) return this.fieldIdsInvalid.push(fieldId);
988995
},

0 commit comments

Comments
 (0)