From ee183e41b3541192be5e60de26ce5e37298b37bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Samuli=20Sillanp=C3=A4=C3=A4?=
 <samuli.sillanpaa@helsinki.fi>
Date: Wed, 30 Oct 2019 15:43:54 +0200
Subject: [PATCH] Translate form element placeholder text also when configured
 via 'settings'. (#1484)

---
 config/vufind/FeedbackForms.yaml       | 4 ++--
 module/VuFind/src/VuFind/Form/Form.php | 7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/config/vufind/FeedbackForms.yaml b/config/vufind/FeedbackForms.yaml
index b0f7cb4519f..445644fb956 100644
--- a/config/vufind/FeedbackForms.yaml
+++ b/config/vufind/FeedbackForms.yaml
@@ -67,8 +67,8 @@
 #     placeholder (string) Placeholder label (translation key). Used to instruct or force
 #       (when combined with 'required' attribute) the user to make a selection from the
 #       options-list. Only select elements with 'options' are supported.
-#       For text, textarea, email and url elements, a placeholder text can be configured
-#       by adding a HTML-attribute via 'settings', for example:
+#       For text, textarea, email and url elements, a placeholder text (translation key)
+#       can be configured by adding a HTML-attribute via 'settings', for example:
 #       settings:
 #         - [placeholder, Please select...]
 #
diff --git a/module/VuFind/src/VuFind/Form/Form.php b/module/VuFind/src/VuFind/Form/Form.php
index 3b937d1c1cd..327726d5c9a 100644
--- a/module/VuFind/src/VuFind/Form/Form.php
+++ b/module/VuFind/src/VuFind/Form/Form.php
@@ -291,7 +291,12 @@ class Form extends \Zend\Form\Form implements
             $settings = [];
             if (isset($el['settings'])) {
                 foreach ($el['settings'] as list($settingId, $settingVal)) {
-                    $settings[trim($settingId)] = trim($settingVal);
+                    $settingId = trim($settingId);
+                    $settingVal = trim($settingVal);
+                    if ($settingId === 'placeholder') {
+                        $settingVal = $this->translate($settingVal);
+                    }
+                    $settings[$settingId] = $settingVal;
                 }
                 $element['settings'] = $settings;
             }
-- 
GitLab