Bugzilla – Attachment 184068 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: Ignore new_guarantor_relationship and patron attribute inputs if they are hidden
0002-Bug-34671-Ignore-new_guarantor_relationship-and-patr.patch (text/plain), 7.19 KB, created by
Emmi Takkinen
on 2025-07-15 05:42:28 UTC
(
hide
)
Description:
Bug 34671: Ignore new_guarantor_relationship and patron attribute inputs if they are hidden
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2025-07-15 05:42:28 UTC
Size:
7.19 KB
patch
obsolete
>From 32ce4269e41b0ba9ded2365bb5a38d2fe2b88755 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Mon, 25 Sep 2023 08:56:18 +0300 >Subject: [PATCH 2/3] Bug 34671: Ignore new_guarantor_relationship and patron > attribute inputs if they are hidden > >Validating patron forms hidden fields causes problems when >adding/modifying guarantee patrons since class >new_guarantor_relationship is always hidden and mandatory >if syspref "borrowerRelationship" is set. Also patron attributes >not used by patron category are still present in form as hidden >and marked as required if they are set as mandatory. This patch >removes and adds attribute required to these fields based on their >visibility. > >To test guarantor relationship: >1. Apply previous patch. >2. Add or modify guarantee patron. >3. Do not add or modify guarantor. >4. Attempt to save patron. >=> Pressing save button does nothing and no error is >displayed. >5. Apply this patch. >6. Again add or modify guarantee patron and don't add or >modify guarantor. >7. Attempt to save. >=> Saving should now be successfull. >8. Again, add or modify guarantee patron, but this time also >add or modify guarantor. >9. Leave relationship input empty. >10. Attempt to save. >=> Saving should fail and error "There are some required >fields missing..." should be displayed on top of "Patron >guarantor" field set. >11. Add relationship for guarantor and save. >=> Saving should now be successfull. > >To test patron attributes: >1. Add patron attribute for patron category A and set it as mandatory. >2. Add patron with category B and fill in required fields. >3. Attempt to save. >=> Error is displayed above "Additional attributes and identifiers" >field set. >4. Apply this patch. >5. Repeat steps 2 and 3. >=> Save successfully. >6. Add new patron with category B, but this time change patrons >category as A from patron form. >=> Confirm that mandatory patron attribute is displayed correctly >and without it patron cannot be saved. > >Sponsored-by: Koha-Suomi Oy >--- > .../prog/en/modules/members/memberentrygen.tt | 22 +++++++++++++++++-- > koha-tmpl/intranet-tmpl/prog/js/members.js | 5 +++++ > 2 files changed, 25 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 361a178107..73e47f105d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -1521,13 +1521,21 @@ > [% END %] > [% FOREACH patron_attribute IN pa_loo.items %] > <li data-category_code="[% patron_attribute.category_code | html %]" data-pa_code="[% patron_attribute.code | replace('[^a-zA-Z0-9_-]', '') %]"> >- [% IF patron_attribute.mandatory %] >+ [% IF patron_attribute.mandatory && patron_attribute.category_code == patron_category.categorycode%] > <label for="[% patron_attribute.form_id | html %]" class="required" required="required">[% patron_attribute.description | html %]: </label> >+ [% ELSIF patron_attribute.mandatory && patron_attribute.category_code != patron_category.categorycode %] >+ <label for="[% patron_attribute.form_id | html %]">[% patron_attribute.description | html %]: </label> > [% ELSE %] > <label for="[% patron_attribute.form_id | html %]">[% patron_attribute.description | html %]: </label> > [% END %] > [% IF ( patron_attribute.use_dropdown ) %] >- <select id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]" [% IF patron_attribute.mandatory %]required="required"[% END %]> >+ [% IF patron_attribute.mandatory && patron_attribute.category_code == patron_category.categorycode %] >+ <select id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]" required="required"> >+ [% ELSIF patron_attribute.mandatory && patron_attribute.category_code != patron_category.categorycode %] >+ <select id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]"> >+ [% ELSE %] >+ <select id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]"> >+ [% END %] > <option value=""></option> > [% FOREACH auth_val_loo IN patron_attribute.auth_val_loop %] > [% IF auth_val_loo.authorised_value == patron_attribute.value %] >@@ -1951,6 +1959,16 @@ > to_api_mapping = [% To.json(to_api_mapping) | $raw %]; > [% END %] > >+ //Remove attribute required so hidden new_guarantor_relationship is not validated >+ if($(".new_guarantor_relationship").is(":hidden")){ >+ $(".new_guarantor_relationship").removeAttr('required');; >+ } >+ >+ //Add attribute required so visible new_guarantor_relationship is validated >+ if($(".new_guarantor_relationship").is(":visible")){ >+ $(".new_guarantor_relationship").prop('required',true); >+ } >+ > var TalkingTechItivaPhoneNotification = [% Koha.Preference('TalkingTechItivaPhoneNotification') || 0 | html %]; > var PhoneNotification = [% Koha.Preference('PhoneNotification') || 0 | html %]; > </script> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js >index 8e7e9b6823..017191cd5c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/members.js >@@ -158,6 +158,11 @@ function select_user(borrowernumber, borrower, relationship) { > $("#guarantor_relationships").append(fieldset); > fieldset.show(); > >+ //Add attribute required so visible new_guarantor_relationship is validated >+ if($(".new_guarantor_relationship").is(":visible")){ >+ $(".new_guarantor_relationship").prop('required',true); >+ } >+ > if (relationship) { > fieldset.find(".new_guarantor_relationship").val(relationship); > } >-- >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