Fixed #CORD-278
diff --git a/xos/core/xoslib/spec/xoslib/xos-helper.test.js b/xos/core/xoslib/spec/xoslib/xos-helper.test.js
new file mode 100644
index 0000000..3ae47b9
--- /dev/null
+++ b/xos/core/xoslib/spec/xoslib/xos-helper.test.js
@@ -0,0 +1,48 @@
+'use strict';
+
+describe('The Xos Helper', () => {
+ var f;
+ beforeEach(() => {
+ f = jasmine.getFixtures();
+ f.fixturesPath = 'base/spec/xoslib/fixtures/xos-utils';
+ });
+
+ describe('XOSDetailView', () => {
+
+ describe('onFormDataInvalid', () => {
+
+ // TODO capire come applicare le funzioni di xosHelper su un template adHoc
+
+ const err = {name: "must start with mysite_"};
+ var view;
+ beforeEach(() => {
+ console.log('ciao');
+ f.set(`
+ <script tpye="text/template" id="fake-template">
+ <div>
+ <input name="name" />
+ </div>
+ </script>
+ `);
+ console.log('zio');
+
+ view = XOSDetailView.extend({
+ template: '#fake-template'
+ });
+ console.log('************' + view);
+ });
+
+ it('should show an error', () => {
+
+ console.log(view);
+
+ view.onFormDataInvalid(err);
+
+
+ expect($('.alert').length).toBe(1);
+ });
+ });
+
+ });
+
+});
\ No newline at end of file
diff --git a/xos/core/xoslib/static/js/xoslib/xosHelper.js b/xos/core/xoslib/static/js/xoslib/xosHelper.js
index 16046ae..f0b72b3 100644
--- a/xos/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/xos/core/xoslib/static/js/xoslib/xosHelper.js
@@ -673,12 +673,17 @@
},
onFormDataInvalid: function(errors) {
+
+
var self=this;
+
var markErrors = function(value, key) {
var $inputElement = self.$el.find("[name='" + key + "']");
var $inputContainer = $inputElement.parent();
//$inputContainer.find(".help-inline").remove();
- var $errorEl = $("<span>", {class: "help-inline error", text: value});
+ // var $errorEl = $("<span>", {class: "help-inline error", text: value});
+ $inputContainer.find(".alert.alert-danger").remove();
+ var $errorEl = $("<span>", {class: "alert alert-danger", text: value});
$inputContainer.append($errorEl).addClass("error");
}
_.each(errors, markErrors);