From e0e776b86c81092e6ad5f17df34a7a9d9b1ff0a2 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Wed, 1 Nov 2023 13:38:08 +0200 Subject: [PATCH] Bug 34671: Ignore validation if patron attribute field is hidden 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 prevents saving patron when validation is required also for hidden fields. This patch adds and removes class "ignore_validation" for these fields based on their visibility. To test: 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 madatory patron attribute is displayed correctly and without it patron cannot be saved. Sponsored-by: Koha-Suomi Oy --- koha-tmpl/intranet-tmpl/prog/js/members.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index f49f11243f..6bdc15e3b5 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -74,6 +74,15 @@ function update_category_code(category_code) { var min_length = $('select'+category_selector+' option:selected').data('pwdLength'); var hint_string = __("Minimum password length: %s").format(min_length); hint.html(hint_string); + + // Add class ignore_validation from attribute field to ignore validation + if($(mytables).find("li").is(":hidden")){ + $(mytables).find("li").children('[id*="patron_attr"]').addClass("ignore_validation"); + } + // Remove class ignore_validation from attribute field so it's validated + if($(mytables).find("li").is(":visible")){ + $(mytables).find("li").children('[id*="patron_attr"]').removeClass("ignore_validation"); + } } function select_user(borrowernumber, borrower, relationship) { -- 2.34.1