Bugzilla – Attachment 156263 Details for
Bug 34671
Collapsing fields in patron form allows saving without mandatory fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34671: Show error message if fieldset has invalid input
0001-Bug-34671-Show-error-message-if-fieldset-has.patch (text/plain), 3.81 KB, created by
Emmi Takkinen
on 2023-09-27 09:29:46 UTC
(
hide
)
Description:
Bug 34671: Show error message if fieldset has invalid input
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2023-09-27 09:29:46 UTC
Size:
3.81 KB
patch
obsolete
>From 5e11fe4198bf51e8f94a77f4b50fe20a313f3085 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Fri, 15 Sep 2023 11:19:35 +0300 >Subject: [PATCH 1/2] Bug 34671: Show error message if fieldset has invalid > input > >If fieldset is collapsed and it contains required fields >patron can be saved without filling these fields. This patch adds >rule ignore as "" in form validation and displayes error message >in fieldsets containing missing required inputs. > >To test: >1. Make sure you have "Main address" fields set as mandatory >with BorrowerMandatoryField syspref (address, city, zipcode) >2. Add new patron, fill in some info, but leave "Main address" >fields empty. >3. Attempt to save. >=> "This field is mandatory" should be displayed next to the >address fields. >4. Collapse "Main address" fieldset. >5. Attempt to save again. >=> Patron is saved successfully without address information. >6. Apply this patch. >7. Edit patron and attempt to save again with "Main address" >fieldset collapsed. >=> Error message "There are some required fields missing from this field set. Please fill them." should be displayed >and patron isn't saved. >8. Fill missing fields, attempt to save. >=> Saving should now be successfull. > >Sponsored-by: Koha-Suomi Oy >--- > .../prog/en/includes/validator-strings.inc | 1 + > koha-tmpl/intranet-tmpl/prog/js/members.js | 19 ++++++++++++++++++- > 2 files changed, 19 insertions(+), 1 deletion(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc >index 87dde3e610..fbc7c0a26f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc >@@ -12,6 +12,7 @@ > digits: _("Please enter only digits."), > equalTo: _("Please enter the same value again."), > number: _("Please add amount in valid format: 0.00"), >+ missing_fields: _("There are some required fields missing from this field set. Please fill them."), > maxlength: $.validator.format(_("Please enter no more than {0} characters.")), > minlength: $.validator.format(_("Please enter at least {0} characters.")), > rangelength: $.validator.format(_("Please enter a value between {0} and {1} characters long.")), >diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js >index dad7ead3a3..ebff6fdb8d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/members.js >@@ -240,6 +240,7 @@ $(document).ready(function(){ > jQuery.validator.messages.phone); > > $("#entryform").validate({ >+ ignore: "", > rules: { > email: { > email: true >@@ -268,7 +269,23 @@ $(document).ready(function(){ > else > form.beenSubmitted = true; > form.submit(); >- } >+ }, >+ invalidHandler: function(form, validator) { >+ var error_msg = jQuery.validator.messages.missing_fields; >+ // First remove error messages so that it doesn't >+ // show in fieldset without errors >+ $("fieldset").each(function(){ >+ $("#"+$(this).attr("id")+"-error").remove(); >+ }); >+ $(validator.errorList).each(function() { >+ var fieldset = $(this.element).parents('[id*="memberentry_"]'); >+ var fieldset_id = fieldset.attr("id"); >+ //Add error message only if it doesn't already exist >+ if(!$("#"+fieldset_id+"-error").length){ >+ fieldset.find("legend").before('<span id="'+fieldset_id+'-error" class="required">'+error_msg+'</span>'); >+ } >+ }); >+ } > }); > > var mrform = $("#manual_restriction_form"); >-- >2.34.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34671
:
155643
|
156145
|
156263
|
156264
|
156453
|
156454
|
158168
|
158299
|
158524
|
158525
|
158526