Bugzilla – Attachment 184067 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.74 KB, created by
Emmi Takkinen
on 2025-07-15 05:41:59 UTC
(
hide
)
Description:
Bug 34671: Show error message if fieldset has invalid input
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2025-07-15 05:41:59 UTC
Size:
3.74 KB
patch
obsolete
>From 0f95ac23e1a62ef1af22bf7a49f3cb259d5426db 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/3] 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 | 17 +++++++++++++++++ > 2 files changed, 18 insertions(+) > >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 dbd32806e5..4335a7f0c3 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 section. Please complete 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 a20561cfe0..8e7e9b6823 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/members.js >@@ -322,6 +322,7 @@ $(document).ready(function () { > ); > > $("#entryform").validate({ >+ ignore: "", > rules: { > email: { > email: true, >@@ -351,6 +352,22 @@ $(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").after('<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
| 184067 |
184068
|
184069
|
185285