From dea52dc0585589d214077521889751a32b8e9b08 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 24 Jul 2024 18:15:05 +0000 Subject: [PATCH] Bug 35044: (QA follow-up): Allow for value '0' in additional fields This now allows for value '0' for an additional field (repeatable or not). This still does not allow for an empty '' field in additional fields. This is consistent with borrower patron attributes, i.e. if you submit an empty borrower patron attribute entry, it does not store it as empty. Additionally, if you have a value in a borrower patron attribute but then submit the form with that field as empty, it gets deleted from the database. I agree not being able to save the value '0' is a blocker, but not the empty. For consistency sake I'm keeping this as is, I don't see a use-case where a row with an empty field value is preferred over it not existing. If we allow for '' values of additional fields, the 'clear' button for repeatable fields would have to remove the input instead of clearing the value (or else how would the user remove repeatable fields entries?). If this is done, it's inconsistent with the repeatable fields from patron attribute types, as in that instance the 'clear' button only removes the input contents, not the input element itself. prove t/db_dependent/Koha/Object/Mixin/AdditionalFields.t --- Koha/Object/Mixin/AdditionalFields.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/Object/Mixin/AdditionalFields.pm b/Koha/Object/Mixin/AdditionalFields.pm index 00718e99ad..80bc266b91 100644 --- a/Koha/Object/Mixin/AdditionalFields.pm +++ b/Koha/Object/Mixin/AdditionalFields.pm @@ -112,7 +112,7 @@ sub prepare_cgi_additional_field_values { push @additional_fields, { id => $field->id, value => $value, - } if $value; + } if defined $value && $value ne ''; } } -- 2.39.2