When adding a new authority record, clicking save (without filling in any fields) doesn't fill in the auto-populated fields such as 000, 003, and 008. In a 24.11.x instance, this works (start up a local instance or use one of the demos): 1. Authorities > New authority > Topical term 2. Don't enter any information in any fields. 3. Click 'save'. 4. Note that fields such as 000 and 003 are auto-populated (not sure if that is the right term). In 25.05.00 or main, this no longer works: 1. Repeat steps 1 to 3. 2. Note that: - fields such as 000 and 003 are not auto-populated - the mandatory fields are now highlighted in yellow - clicking the individual fields doesn't auto-populate them
See Mattermost chat discussion (8 June 2025): https://chat.koha-community.org/koha-community/pl/akiuk7i73b8qmd38haaxrq7z5o
We're preparing to upgrade our production to 25.05, so we've been doing thorough beta testing with librarians with our Finnish libraries. During this testing, we discovered that the main MARC records interface is also affected by the same issue. We found why, prepared a fix, and post-checked with librarians that this bug is gone. The root cause is in the JavaScript function `AreMandatoriesNotOk`, which uses hardcoded rewriting of classes, so it removed recently announced `framework_plugin` calss: elt.setAttribute('class', 'input_marceditor noEnterSubmit ' + notFilledClass); so our solution is to expand hardcoded line with the class: elt.setAttribute('class', 'input_marceditor noEnterSubmit framework_plugin ' + notFilledClass); or, better yet, or, if that does not creates any other border cases, completely replace the hardcoded class assignment with a more flexible method: elt.classList.add(notFilledClass); Code below.
Created attachment 183124 [details] [review] Bug 40092: Fill auto-populated control fields in MARC editors Problem: Clicking Save doesn't fill control fields automatically in both the authority and bibliographic MARC editors. Regression introduced when class `framework_plugin` was added: `AreMandatoriesNotOk()` rewrites the element `class` attribute with a hard‑coded string, dropping existing classes. Because the plugins that populate 000/003/005/008 rely on `framework_plugin`, the inputs are skipped and the fields remain empty. This patch stops clobbering the attribute and instead appends the visual 'notFilled' class via `elt.classList.add()`. The one-line fix is applied in both `authorities.tt` and `addbiblio.tt`. Test plan: Authority editor 1. Authorities → New authority → choose framework (e.g. Topical term). 2. Leave all fields blank, click Save. Before patch: 000, 003, 008 remain blank; required tags turn yellow. 3. Apply patch, hard‑refresh, repeat steps 1–2. After patch: control fields auto‑populate as in 24.11. Bibliographic editor 1. Cataloguing → New record (Not in Advanced MARC editor). 2. Click Save without entering data. Before patch: control fields stay blank; record cannot be saved. 3. Apply patch, hard‑refresh, repeat. After patch: record is blocked, but 000/005/008 auto‑populate. Both editors behave like 24.11; mandatory highlighting still works.
one thing to decide: I put both variants in code, one commented out so we should throw it away if second more elegant (and future-for-new-classes-proof) one is better and works: // elt.setAttribute('class','input_marceditor noEnterSubmit framework_plugin ' + notFilledClass); or .classList.add(notFilledClass);
I tried the proposed solution as I was also experiencing no auto-population on 000,003,005,and 008 in cataloging coming from 23 to 25.05. I just tried adding a new MARC record and just pressed save (no data entry) and now the fields 000,003,005,and 008 all populate as they did before. I have the lines commented out as recommended.
Created attachment 183159 [details] [review] Bug 40092: Fill auto-populated control fields in MARC editors Problem: Clicking Save doesn't fill control fields automatically in both the authority and bibliographic MARC editors. Regression introduced when class `framework_plugin` was added: `AreMandatoriesNotOk()` rewrites the element `class` attribute with a hard‑coded string, dropping existing classes. Because the plugins that populate 000/003/005/008 rely on `framework_plugin`, the inputs are skipped and the fields remain empty. This patch stops clobbering the attribute and instead appends the visual 'notFilled' class via `elt.classList.add()`. The one-line fix is applied in both `authorities.tt` and `addbiblio.tt`. Test plan: Authority editor 1. Authorities → New authority → choose framework (e.g. Topical term). 2. Leave all fields blank, click Save. Before patch: 000, 003, 008 remain blank; required tags turn yellow. 3. Apply patch, hard‑refresh, repeat steps 1–2. After patch: control fields auto‑populate as in 24.11. Bibliographic editor 1. Cataloguing → New record (Not in Advanced MARC editor). 2. Click Save without entering data. Before patch: control fields stay blank; record cannot be saved. 3. Apply patch, hard‑refresh, repeat. After patch: record is blocked, but 000/005/008 auto‑populate. Both editors behave like 24.11; mandatory highlighting still works. Signed-off-by: David Nind <david@davidnind.com>
Notes for QA phase: we need to decide if `.classList.add(notFilledClass);` is universal and do not interfere/future proof (looks like). If so, then remove another proposed but commented out solution `// elt.setAttribute...`.
It would also be nice to have a test for this, if it is possible (I have no idea how to create them myself!). That would help avoid breaking the feature again in the future.
I changed the status to major, ideally so that this can be fixed in the first maintenance release for 25.05.