From b1e3ef78810f6d5ac53253d66c9bed32b145c352 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 13 Jan 2026 20:09:30 +0100 Subject: [PATCH] Fixed `%` handling in Userfield captions (fixes #2856) --- changelog/81_UNRELEASED_xxxx-xx-xx.md | 4 ++-- views/components/userfieldsform.blade.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/changelog/81_UNRELEASED_xxxx-xx-xx.md b/changelog/81_UNRELEASED_xxxx-xx-xx.md index f1d41009..41ed0019 100644 --- a/changelog/81_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/81_UNRELEASED_xxxx-xx-xx.md @@ -12,7 +12,7 @@ - Optimized the line plot markers color of the price history chart (product card) (thanks @DeepCoreSystem) - External barcode lookup plugin optimizations: - - When an image URL without a file extension ist returned, the file extension is now determined by the Content-Type header (if any) (thanks @jordy-u for the idea) + - When an image URL without a file extension is returned, the file extension is now determined by the Content-Type header (if any) (thanks @jordy-u for the idea) - Data URLs for images are now supported (`data:image/png;base64,xxxx`) (thanks @GammaC0de) - Fixed that German Umlauts were removed from product names when looking up a barcode via the built-in Open Food Facts external barcode lookup plugin - Fixed that when using/scanning a barcode on the purchase page with a note attached (which prefills the note field) and when manually selecting another product afterwards, the note of the previously used barcode was incorrectly prefilled again @@ -53,7 +53,7 @@ ### Userfields -- xxx +- Fixed that the corresponding form was broken when using a `%` in an Userfield caption (only affected numeric and date-time Userfields) ### General diff --git a/views/components/userfieldsform.blade.php b/views/components/userfieldsform.blade.php index 59224093..b4c35fee 100644 --- a/views/components/userfieldsform.blade.php +++ b/views/components/userfieldsform.blade.php @@ -37,7 +37,7 @@ @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_NUMBER_INT) @include('components.numberpicker', array( 'id' => $userfield->name, - 'label' => $userfield->caption, + 'label' => str_replace('%', '%%', $userfield->caption), // Escape % (there are placeholders in Gettext translation strings) 'noNameAttribute' => true, 'min' => 0, 'isRequired' => $userfield->input_required == 1, @@ -48,7 +48,7 @@ @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_NUMBER_DECIMAL) @include('components.numberpicker', array( 'id' => '', - 'label' => $userfield->caption, + 'label' => str_replace('%', '%%', $userfield->caption), // Escape % (there are placeholders in Gettext translation strings) 'noNameAttribute' => true, 'min' => 0, 'decimals' => 4, @@ -60,7 +60,7 @@ @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_NUMBER_CURRENCY) @include('components.numberpicker', array( 'id' => '', - 'label' => $userfield->caption, + 'label' => str_replace('%', '%%', $userfield->caption), // Escape % (there are placeholders in Gettext translation strings) 'noNameAttribute' => true, 'min' => 0, 'decimals' => 4, @@ -72,7 +72,7 @@ @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_DATE) @include('components.datetimepicker2', array( 'id' => $userfield->name, - 'label' => $userfield->caption, + 'label' => str_replace('%', '%%', $userfield->caption), // Escape % (there are placeholders in Gettext translation strings) 'noNameAttribute' => true, 'format' => 'YYYY-MM-DD', 'initWithNow' => false, @@ -86,7 +86,7 @@ @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_DATETIME) @include('components.datetimepicker2', array( 'id' => $userfield->name, - 'label' => $userfield->caption, + 'label' => str_replace('%', '%%', $userfield->caption), // Escape % (there are placeholders in Gettext translation strings) 'noNameAttribute' => true, 'format' => 'YYYY-MM-DD HH:mm:ss', 'initWithNow' => false,