Bug 40869 - Preserve mandatory fields even if hidden when duplicating item
Summary: Preserve mandatory fields even if hidden when duplicating item
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: David Gustafsson
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-24 12:42 UTC by David Gustafsson
Modified: 2025-09-24 14:47 UTC (History)
1 user (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40869: Preserve mandatory fields even if hidden when duplicating item (4.40 KB, patch)
2025-09-24 13:01 UTC, David Gustafsson
Details | Diff | Splinter Review
Bug 40869: Fix tests and documentation after changing argument name (2.07 KB, patch)
2025-09-24 14:23 UTC, David Gustafsson
Details | Diff | Splinter Review
Bug 40869: Fix incorrect argument name (1.08 KB, patch)
2025-09-24 14:47 UTC, David Gustafsson
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Gustafsson 2025-09-24 12:42:35 UTC
When item fields are mandatory, which usually indicate they are somehow critical for functionality and expected to exist in Koha, it makes sense they should be preserved when duplicating an item, even if the field is hidden. Right now hidden fields are ignored using the "ignore_invisible_subfields" option in the form builder for item. If for current library (holding branch) is hidden (which is the case for our library), the biblio page will crash after duplicating an item, which now has a missing holding branch. Fixing this is simple by adding a check for the mandatory attribute in the check for "ignore_invisible_subfields" (I also renamed this option to "ignore_non_mandatory_invisible_subfields" for clarity.
Comment 1 David Gustafsson 2025-09-24 13:01:39 UTC
Created attachment 186878 [details] [review]
Bug 40869: Preserve mandatory fields even if hidden when duplicating item

Preserve mandatory fields while when duplicating an item, also when they
are non visible.

To test:
1) Go to MARC bibliographic framwork and view the marc structure for
   some framework.
2) Select edit subfield b for tag 952 and make it non visible
3) Go to a biblio using the framework above and edit an item. In the
   "actions" dropdown, choose to duplicate an item.
4) Now go to the detail page for the biblio, "Current library" should be
   empty and it should produce a 500 error.
5) Apply patch.
6) Perform steps 3-4 for some other biblio using the same framework.
7) The "Current library" should now be set to the same value as the
   source item, and no crash should occur.

Sponsored-by: Gothenburg University Library
Comment 2 David Gustafsson 2025-09-24 14:23:08 UTC
Created attachment 186885 [details] [review]
Bug 40869: Fix tests and documentation after changing argument name
Comment 3 David Gustafsson 2025-09-24 14:47:06 UTC
Created attachment 186887 [details] [review]
Bug 40869: Fix incorrect argument name