NIHVIVO-377 When a custom form fails validation due to a missing organization, the server generates an error appropriate to the non-Javascript version of the form, and the Javascript then modifies it for the Javascript version of the form.
This commit is contained in:
parent
1f2b200320
commit
a5f9d133c0
1 changed files with 14 additions and 9 deletions
|
@ -124,14 +124,9 @@ var customForm = {
|
||||||
this.defaultButtonText = 'Create ' + this.entryType;
|
this.defaultButtonText = 'Create ' + this.entryType;
|
||||||
this.addNewButtonText = 'Create ' + this.secondaryType + ' & ' + this.entryType;
|
this.addNewButtonText = 'Create ' + this.secondaryType + ' & ' + this.entryType;
|
||||||
|
|
||||||
// If there are validation errors on the page, we're returning from
|
// If a returnView has been specified in the hidden input field, it means we are
|
||||||
// an attempted submission that failed validation, and we need to go
|
// returning from a failed submission due to validation errors. We need to restore
|
||||||
// directly to step 2.
|
// the view we were on when the form was submitted.
|
||||||
// if (this.findValidationErrors()) {
|
|
||||||
// this.doAddFormStep2();
|
|
||||||
// } else {
|
|
||||||
// this.doAddFormStep1();
|
|
||||||
// }
|
|
||||||
if (this.returnView) {
|
if (this.returnView) {
|
||||||
this.doAddFormStep2(this.returnView);
|
this.doAddFormStep2(this.returnView);
|
||||||
} else {
|
} else {
|
||||||
|
@ -397,6 +392,10 @@ var customForm = {
|
||||||
customForm.addNewLink.hide();
|
customForm.addNewLink.hide();
|
||||||
customForm.hideFields(customForm.addNew);
|
customForm.hideFields(customForm.addNew);
|
||||||
customForm.showFieldsForAllViews();
|
customForm.showFieldsForAllViews();
|
||||||
|
|
||||||
|
// Adjust the validation error that has been inserted by the server, which
|
||||||
|
// is phrased appropriately for the non-Javascript version of the form.
|
||||||
|
$('#organizationUri_validationError').html('Must select an organization.');
|
||||||
},
|
},
|
||||||
|
|
||||||
showAddNewFields: function() {
|
showAddNewFields: function() {
|
||||||
|
@ -405,6 +404,10 @@ var customForm = {
|
||||||
customForm.addNewLink.hide();
|
customForm.addNewLink.hide();
|
||||||
customForm.addNew.show();
|
customForm.addNew.show();
|
||||||
customForm.showFieldsForAllViews();
|
customForm.showFieldsForAllViews();
|
||||||
|
|
||||||
|
// Adjust the validation error that has been inserted by the server, which
|
||||||
|
// is phrased appropriately for the non-Javascript version of the form.
|
||||||
|
$('#newOrgName_validationError').html('Must specify an organization.');
|
||||||
},
|
},
|
||||||
|
|
||||||
// This version of the form shows both the existing select and add new link.
|
// This version of the form shows both the existing select and add new link.
|
||||||
|
@ -443,6 +446,8 @@ var customForm = {
|
||||||
action == 'show' ? hints.show() : hints.hide();
|
action == 'show' ? hints.show() : hints.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Set the hidden input field indicating the view to return to if
|
||||||
|
// the submission fails due to validation errors.
|
||||||
setReturnView: function(value) {
|
setReturnView: function(value) {
|
||||||
customForm.returnViewField.val(value);
|
customForm.returnViewField.val(value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue