Bug 30319: Remove appropriate hidden fields on self-modification

Previously, the system preference
PatronSelfRegistrationBorrowerUnwantedField was used to remove hidden
fields regardless of whether the operation was self-registration or
self-modification. This patch uses the appropriate set of hidden fields
depending on the current operation (create/update).

Test plan:
1.  Set OPACPatronDetails to "Allow".
2.  Ensure PatronSelfModificationBorrowerUnwantedField is empty.
3.  Set PatronSelfRegistrationBorrowerUnwantedField to exclude
    Title (towards the bottom right of the modal).
4.  Log into the OPAC, and navigate to Your account > Personal details.
5.  Change your title and submit the request.
6.  Verify you see the notice "No changes were made." at the top of the
    page.
7.  Apply patch.
8.  Change your title again and submit the request.
9.  Verify the request is submitted successfully.
10. Return to the personal details screen, but don't submit.
11. Set PatronSelfModificationBorrowerUnwantedField to exclude Title.
12. On the preloaded personal details screen, update the title and
    submit.
13. Verify you see the notice "No changes were made." at the top of the
    page.

Sponsored-by: Open Fifth
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Olivia Reynolds 2026-08-06 14:20:58 +00:00 committed by Pedro Amorim
parent 0fc43dd5a3
commit 6975b6616b
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 10 additions and 5 deletions

View File

@ -130,7 +130,7 @@ foreach my $attr (@$attributes) {
if ( $op eq 'cud-create' ) { if ( $op eq 'cud-create' ) {
my %borrower = ParseCgiForBorrower($cgi); my %borrower = ParseCgiForBorrower( { cgi => $cgi, op => $op } );
%borrower = DelEmptyFields(%borrower); %borrower = DelEmptyFields(%borrower);
$borrower{categorycode} ||= $PatronSelfRegistrationDefaultCategory; $borrower{categorycode} ||= $PatronSelfRegistrationDefaultCategory;
@ -312,7 +312,7 @@ if ( $op eq 'cud-create' ) {
my $borrower = Koha::Patrons->find($borrowernumber)->unblessed; my $borrower = Koha::Patrons->find($borrowernumber)->unblessed;
my %borrower = ParseCgiForBorrower($cgi); my %borrower = ParseCgiForBorrower( { cgi => $cgi, op => $op } );
$borrower{borrowernumber} = $borrowernumber; $borrower{borrowernumber} = $borrowernumber;
$borrower{categorycode} = $borrower->{categorycode}; $borrower{categorycode} = $borrower->{categorycode};
@ -565,7 +565,9 @@ sub CheckForInvalidFields {
} }
sub ParseCgiForBorrower { sub ParseCgiForBorrower {
my ($cgi) = @_; my ($params) = @_;
my $cgi = $params->{cgi};
my $op = $params->{op};
my $scrubber = C4::Scrubber->new(); my $scrubber = C4::Scrubber->new();
my %borrower; my %borrower;
@ -595,8 +597,11 @@ sub ParseCgiForBorrower {
for for
qw/dateenrolled dateexpiry borrowernotes opacnote sort1 sort2 sms_provider_id autorenew_checkouts gonenoaddress lost relationship/ qw/dateenrolled dateexpiry borrowernotes opacnote sort1 sort2 sms_provider_id autorenew_checkouts gonenoaddress lost relationship/
; # On OPAC only ; # On OPAC only
delete $borrower{$_}
for split( /\s*\|\s*/, C4::Context->preference('PatronSelfRegistrationBorrowerUnwantedField') || q{} ); # Delete fields hidden from this operation
my $mandatory = GetMandatoryFields($op);
my $hidden = GetHiddenFields( $mandatory, $op );
delete $borrower{$_} for keys %$hidden;
return %borrower; return %borrower;
} }