Bug 39828 - QuickAdd skips fields from PatronQuickAddFields in some cases
Summary: QuickAdd skips fields from PatronQuickAddFields in some cases
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Slava Shishkin
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-05 09:18 UTC by Slava Shishkin
Modified: 2025-05-06 13:49 UTC (History)
3 users (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 39828: Fix QuickAdd skipping fields (1.93 KB, patch)
2025-05-05 09:30 UTC, Slava Shishkin
Details | Diff | Splinter Review
Bug 39828: Fix QuickAdd skipping fields (2.00 KB, patch)
2025-05-06 13:48 UTC, Chloé Zermatten
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Slava Shishkin 2025-05-05 09:18:46 UTC
When using PatronQuickAddFields to add fields to the Quick Add form, fields that exist in the main form but contain multiple input elements (especially hidden/disabled ones) may be silently skipped during QuickAdd form generation.

Example:
"userid" field exists in the full patron form (entryform) as:

> <li>
>   <label for="userid">Username:</label>
>   <input type="text" id="userid" name="userid" ...>
>   <input type="text" disabled="disabled" style="display:none" ...>
> </li>


The current JavaScript logic to detect and clone these fields uses:

> let orig_input_id = orig_li.children("input,textarea,select").last().attr("id");


In this example, .last() selects the hidden disabled input without an id → orig_input_id becomes undefined → and the field is not cloned into QuickAdd form.

Result: userid is missing from Quick Add even though it's included in PatronQuickAddFields.

Steps to reproduce:
1. Add userid (or any other field that matches above structure) to PatronQuickAddFields.
2. Open the Add Patron form and use Quick Add.
3. Observe → the field is missing.
Comment 1 Slava Shishkin 2025-05-05 09:30:16 UTC
Created attachment 181902 [details] [review]
Bug 39828: Fix QuickAdd skipping fields

Currently, fields like userid are skipped if the last input in the main form
is hidden or has no ID. This patch fixes the selection logic to avoid skipping.

Steps to reproduce:
1. Add userid (or any other field that matches above structure) to PatronQuickAddFields.
2. Open the Add Patron form and use Quick Add.
3. Observe → the field is missing.
4. Apply the patch.
5. Use Quick Add again and observe that 'Username' field is there.
Comment 2 Chloé Zermatten 2025-05-06 13:48:43 UTC
Created attachment 181972 [details] [review]
Bug 39828: Fix QuickAdd skipping fields

Currently, fields like userid are skipped if the last input in the main form
is hidden or has no ID. This patch fixes the selection logic to avoid skipping.

Steps to reproduce:
1. Add userid (or any other field that matches above structure) to PatronQuickAddFields.
2. Open the Add Patron form and use Quick Add.
3. Observe → the field is missing.
4. Apply the patch.
5. Use Quick Add again and observe that 'Username' field is there.

Signed-off-by: Chloe Zermatten <chloe.zermatten@openfifth.co.uk>