Skip to content
Snippets Groups Projects
Commit ee183e41 authored by Samuli Sillanpää's avatar Samuli Sillanpää Committed by Robert Lange
Browse files

Translate form element placeholder text also when configured via 'settings'. (#1484)

parent 90a89227
No related merge requests found
...@@ -67,8 +67,8 @@ ...@@ -67,8 +67,8 @@
# placeholder (string) Placeholder label (translation key). Used to instruct or force # placeholder (string) Placeholder label (translation key). Used to instruct or force
# (when combined with 'required' attribute) the user to make a selection from the # (when combined with 'required' attribute) the user to make a selection from the
# options-list. Only select elements with 'options' are supported. # options-list. Only select elements with 'options' are supported.
# For text, textarea, email and url elements, a placeholder text can be configured # For text, textarea, email and url elements, a placeholder text (translation key)
# by adding a HTML-attribute via 'settings', for example: # can be configured by adding a HTML-attribute via 'settings', for example:
# settings: # settings:
# - [placeholder, Please select...] # - [placeholder, Please select...]
# #
......
...@@ -291,7 +291,12 @@ class Form extends \Zend\Form\Form implements ...@@ -291,7 +291,12 @@ class Form extends \Zend\Form\Form implements
$settings = []; $settings = [];
if (isset($el['settings'])) { if (isset($el['settings'])) {
foreach ($el['settings'] as list($settingId, $settingVal)) { 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; $element['settings'] = $settings;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment