diff --git a/dist/simple-form.bootstrap4.esm.js b/dist/simple-form.bootstrap4.esm.js index 5ab3ec9..4b28055 100644 --- a/dist/simple-form.bootstrap4.esm.js +++ b/dist/simple-form.bootstrap4.esm.js @@ -23,6 +23,7 @@ ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { wrappers: { "default": { add: function add(element, settings, message) { + alert('bla'); var wrapperElement = element.parent(); var errorElement = wrapperElement.find(settings.error_tag + '.invalid-feedback'); diff --git a/dist/simple-form.bootstrap4.js b/dist/simple-form.bootstrap4.js index 431ad3c..feaf840 100644 --- a/dist/simple-form.bootstrap4.js +++ b/dist/simple-form.bootstrap4.js @@ -29,6 +29,7 @@ wrappers: { "default": { add: function add(element, settings, message) { + alert('bla'); var wrapperElement = element.parent(); var errorElement = wrapperElement.find(settings.error_tag + '.invalid-feedback'); diff --git a/dist/simple-form.esm.js b/dist/simple-form.esm.js index 79ee074..8a1365d 100644 --- a/dist/simple-form.esm.js +++ b/dist/simple-form.esm.js @@ -23,6 +23,12 @@ ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { wrappers: { "default": { add: function add(element, settings, message) { + console.log(this); + + if (element.is('select') && (element.hasClass('date') || element.hasClass('time'))) { + console.log(this); + } + var wrapper = element.closest(settings.wrapper_tag + '.' + settings.wrapper_class.replace(/ /g, '.')); var errorElement = wrapper.find(settings.error_tag + '.' + settings.error_class.replace(/ /g, '.')); @@ -44,15 +50,6 @@ ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { return errorElement.remove(); } }, - - get horizontal_multi_select() { - return this.multi_select; - }, - - get vertical_multi_select() { - return this.multi_select; - }, - multi_select: { add: function add(element, settings, message) { var wrapperElement = element.closest(settings.wrapper_tag + '.' + settings.wrapper_class.replace(/ /g, '.')); diff --git a/dist/simple-form.js b/dist/simple-form.js index 980273e..42ad6b1 100644 --- a/dist/simple-form.js +++ b/dist/simple-form.js @@ -29,6 +29,12 @@ wrappers: { "default": { add: function add(element, settings, message) { + console.log(this); + + if (element.is('select') && (element.hasClass('date') || element.hasClass('time'))) { + console.log(this); + } + var wrapper = element.closest(settings.wrapper_tag + '.' + settings.wrapper_class.replace(/ /g, '.')); var errorElement = wrapper.find(settings.error_tag + '.' + settings.error_class.replace(/ /g, '.')); @@ -50,15 +56,6 @@ return errorElement.remove(); } }, - - get horizontal_multi_select() { - return this.multi_select; - }, - - get vertical_multi_select() { - return this.multi_select; - }, - multi_select: { add: function add(element, settings, message) { var wrapperElement = element.closest(settings.wrapper_tag + '.' + settings.wrapper_class.replace(/ /g, '.')); diff --git a/src/main.js b/src/main.js index 832f12e..8249555 100644 --- a/src/main.js +++ b/src/main.js @@ -18,6 +18,10 @@ ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { wrappers: { default: { add (element, settings, message) { + if (element.is('select') && (element.hasClass('date') || element.hasClass('time'))) { + console.log(this.wrappers.multi_select.add(element, settings, message)) + } + const wrapper = element.closest(settings.wrapper_tag + '.' + settings.wrapper_class.replace(/ /g, '.')) var errorElement = wrapper.find(settings.error_tag + '.' + settings.error_class.replace(/ /g, '.')) @@ -38,12 +42,6 @@ ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { return errorElement.remove() } }, - get horizontal_multi_select () { - return this.multi_select - }, - get vertical_multi_select () { - return this.multi_select - }, multi_select: { add (element, settings, message) { const wrapperElement = element.closest(settings.wrapper_tag + '.' + settings.wrapper_class.replace(/ /g, '.')) diff --git a/test/javascript/public/test/form_builders/validateSimpleForm.js b/test/javascript/public/test/form_builders/validateSimpleForm.js index 3643175..4a324c8 100644 --- a/test/javascript/public/test/form_builders/validateSimpleForm.js +++ b/test/javascript/public/test/form_builders/validateSimpleForm.js @@ -12,7 +12,7 @@ QUnit.module('Validate SimpleForm', { dataCsv = { html_settings: { type: 'SimpleForm::FormBuilder', - error_class: 'error small', + error_class: 'error', error_tag: 'span', wrapper_error_class: 'field_with_errors', wrapper_tag: 'div', diff --git a/test/javascript/public/test/form_builders/validateSimpleFormBootstrap4Datetime.js b/test/javascript/public/test/form_builders/validateSimpleFormBootstrap4Datetime.js new file mode 100644 index 0000000..29b8cfa --- /dev/null +++ b/test/javascript/public/test/form_builders/validateSimpleFormBootstrap4Datetime.js @@ -0,0 +1,170 @@ +QUnit.module('Validate SimpleForm Bootstrap 4 Datetime Fields/Wrappers', { + before: function () { + currentFormBuilder = window.ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] + window.ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = BS4_FORM_BUILDER + }, + + after: function () { + window.ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = currentFormBuilder + }, + + beforeEach: function () { + dataCsv = { + html_settings: { + type: 'SimpleForm::FormBuilder', + error_class: null, + error_tag: 'div', + wrapper_error_class: 'form-group-invalid', + wrapper_tag: 'div', + wrapper_class: 'form-group' + }, + validators: { + 'user[date_of_birth]': { presence: [{ message: 'must be present' }] }, + 'user[time_of_birth]': { presence: [{ message: 'must be present' }] } + } + } + + $('#qunit-fixture') + .append( + $('