Bug 40807

Summary: Quick add form does not include 'username' when it is included in BorrowerMandatoryFields
Product: Koha Reporter: Chloé Zermatten <chloe.zermatten>
Component: PatronsAssignee: Chloé Zermatten <chloe.zermatten>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: gmcharlt, kyle
Version: Main   
Hardware: All   
OS: All   
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 40807: fix: username field in quick add form

Description Chloé Zermatten 2025-09-15 08:12:41 UTC
The username field does not seem to appear on the quick add form when it is added to the list of mandatory / required fields in BorrowerMandatoryField, despite appearing as required on the full 'Add patron' form.

Found on 24.11, 25.05, and main.

(This occurs regardless of the number of mandatory fields selected.)

To replicate:

1. Login to the Koha staff interface
2. Search system preferences for BorrowerMandatoryField
3. Toggle on Username (userid)
4. Navigate to /cgi-bin/koha/members/memberentry.pl?op=add_form&categorycode=PT, notice that username shows and is marked as required
5. Navigate to /cgi-bin/koha/members/memberentry.pl?op=add_form&categorycode=PT&quickadd=true, notice no username field shows.
Comment 1 Chloé Zermatten 2025-09-15 10:01:41 UTC
The issue seems to be that the
<input type="text" disabled="disabled" style="display:none" />
dummy input added "avoid Firefox from using userid/password saved for authentication" as per the code comment does not play ball with the change introduced by Bug 38459, which modifies the origin_input_id check to ensure that we check the value of the last child.

The simplest (though maybe slightly hack-y?) solution appears to be to just invert the order of the input fields in the template, so the last child is the true input.

Patch coming up.
Comment 2 Chloé Zermatten 2025-09-15 10:15:19 UTC
Created attachment 186400 [details] [review]
Bug 40807: fix: username field in quick add form

The username field would not appear in the quick add form despite being marked as required in BorrowerMandatoryField.
This was due the interaction between a change introduced by Bug 38459 and the dummy input for the username field.

This patch moves the dummy input so that the true input is the last child that the change in Bug 38459 targets.
This allows the username field to appear when added to BorrowerMandatoryField.

Test plan:
0. (Before applying the patch, follow the replication tests as in the comment above.)
1. Login to the Koha staff interface
2. Search system preferences for BorrowerMandatoryField
3. Toggle on Username (userid) so it is added to the list of fields and save your changes.
4. Navigate to /cgi-bin/koha/members/memberentry.pl?op=add_form&categorycode=PT, notice that username still shows and is marked as required
5. Navigate to /cgi-bin/koha/members/memberentry.pl?op=add_form&categorycode=PT&quickadd=true, notice that the username field does show.