From 1ae850eaf8933b8e7908535f0a308b38c5726809 Mon Sep 17 00:00:00 2001 From: Rafael Ostertag <rafael.ostertag@math.uzh.ch> Date: Mon, 30 Jan 2017 14:32:35 +0100 Subject: [PATCH] Partially fixes https://project.math.uzh.ch/issues/3066: Once the hidden class has been remove in order to display the validation message, it won't be re-added upon validation success. --- javascript/src/QfqForm.js | 10 ++++++++++ mockup/personmock.html | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/javascript/src/QfqForm.js b/javascript/src/QfqForm.js index d0f2cdf0f..960d44fcb 100644 --- a/javascript/src/QfqForm.js +++ b/javascript/src/QfqForm.js @@ -91,10 +91,20 @@ var QfqNS = QfqNS || {}; n.Helper.tinyMce(); this.form.on('form.submit.before', n.Helper.tinyMce.prepareSave); this.form.on('form.validation.before', n.Helper.tinyMce.prepareSave); + this.form.on('form.validation.after', this.showHiddenErrors); }; n.QfqForm.prototype.on = n.EventEmitter.onMixin; + /** + * @private + */ + n.QfqForm.prototype.showHiddenErrors = function (info) { + if (info.data.validationResult === false) { + info.target.$form.find('.with-errors').filter('.hidden').removeClass('hidden'); + } + }; + /** * @private */ diff --git a/mockup/personmock.html b/mockup/personmock.html index e20f5ab03..23e718861 100644 --- a/mockup/personmock.html +++ b/mockup/personmock.html @@ -147,7 +147,7 @@ <div class="col-md-6"> <input id="firstname" name="firstname" type="text" class="form-control" required> - <div class="help-block with-errors"></div> + <div class="help-block with-errors hidden"></div> </div> </div> -- GitLab