Bug 40459: Preferred name is lost when editing partial record

To test:
* on the patron page click edit at the top, entered a preferred name, and hit save
  * we should see the preferred name being displayed instead of the first name for the user
* go back to the main edit page and change the preferred name to a blank space
  * We should revert back to the first name being used
* if we open the edit page back up we should see the first name in the preferred name field
* Edit the preferred name again and click on details
* open up any of the sections other then contact information
* hit the save button on the section without changing anything
  * you should still see the preferred name you set being used.
* open up an individual section other then contact method, change a value, then save
  * you should still see the preferred name you set being used.
* open up the contact information section and save without changing anything
  * the preferred name should be intact
* open up the contact information and change the preferred name, and save.
  * you should see the new preferred name reflected.
* Open up the contact information section, change the preferred name field to a blank and save.
  * you should see the first name being used now.
* Open up the contact information section, and put any number of spaces in the preferred name with nothing else and then save.
  * you should still see the first name being used.

Signed-off-by: CJ Lynce <cj.lynce@westlakelibrary.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4356c14d29)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Imani Thomas 2025-07-21 16:56:34 +00:00 committed by Paul Derscheid
parent 4afb657fe8
commit bdefe52d46
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 3 additions and 1 deletions

View File

@ -550,7 +550,9 @@ if ( ( !$nok ) and $nodouble and ( $op eq 'cud-insert' or $op eq 'cud-save' ) )
$patron = Koha::Patrons->find($borrowernumber);
# Ensure preferred name is set even if not passed because of BorrowerUnwantedFields
$newdata{preferred_name} = undef unless defined $newdata{preferred_name};
if ( $step == 0 or $step == 1 ) {
$newdata{preferred_name} = undef unless defined $newdata{preferred_name};
}
if ($NoUpdateEmail) {
delete $newdata{'email'};