From f763642962341518b777f04ae98d2ed2f5e8764e Mon Sep 17 00:00:00 2001 From: Ruud van Lent Date: Thu, 21 Nov 2024 09:38:05 +0100 Subject: [PATCH 1/9] Add attribute to fix B/C issue in list form field --- libraries/src/Form/Field/ListField.php | 17 ++++++----- libraries/src/Form/FormField.php | 42 ++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/libraries/src/Form/Field/ListField.php b/libraries/src/Form/Field/ListField.php index 191eb0b909c60..472a62ba7b730 100644 --- a/libraries/src/Form/Field/ListField.php +++ b/libraries/src/Form/Field/ListField.php @@ -135,12 +135,12 @@ protected function getOptions() $selected = ($selected === 'true' || $selected === 'selected' || $selected === '1'); $tmp = [ - 'value' => $value, - 'text' => Text::alt($text, $fieldname), - 'disable' => $disabled, - 'class' => (string) $option['class'], - 'selected' => ($checked || $selected), - 'checked' => ($checked || $selected), + 'value' => $value, + 'text' => Text::alt($text, $fieldname), + 'disable' => $disabled, + 'class' => (string) $option['class'], + 'selected' => ($checked || $selected), + 'checked' => ($checked || $selected), ]; // Set some event handler attributes. But really, should be using unobtrusive js. @@ -191,7 +191,10 @@ protected function getOptions() foreach ($options as $option) { if ($option->value === $value) { $value = $option->text; - $tmp->optionattr = ['data-global-value' => $option->value]; + + if (!$this->showonlocal) { + $tmp->optionattr = ['data-global-value' => $option->value]; + } break; } diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index c0c0c9274662f..e0f26f9868d72 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -344,6 +344,14 @@ abstract class FormField implements DatabaseAwareInterface, CurrentUserInterface */ protected $showon; + /** + * Use the global (inherited) field value or local set field value on showon. + * + * @var boolean + * @since 3.2 + */ + protected $showonlocal = false; + /** * The parent class of the field * @@ -473,6 +481,7 @@ public function __get($name) case 'spellcheck': case 'validationtext': case 'showon': + case 'showonlocal': case 'parentclass': return $this->$name; @@ -565,6 +574,7 @@ public function __set($name, $value) case 'readonly': case 'autofocus': case 'hidden': + case 'showonlocal': $value = (string) $value; $this->$name = ($value === 'true' || $value === $name || $value === '1'); break; @@ -656,9 +666,35 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) $this->group = $group; $attributes = [ - 'multiple', 'name', 'id', 'hint', 'class', 'description', 'labelclass', 'onchange', 'onclick', 'validate', 'pattern', 'validationtext', - 'default', 'required', 'disabled', 'readonly', 'autofocus', 'hidden', 'autocomplete', 'spellcheck', 'translateHint', 'translateLabel', - 'translate_label', 'translateDescription', 'translate_description', 'size', 'showon', ]; + 'multiple', + 'name', + 'id', + 'hint', + 'class', + 'description', + 'labelclass', + 'onchange', + 'onclick', + 'validate', + 'pattern', + 'validationtext', + 'default', + 'required', + 'disabled', + 'readonly', + 'autofocus', + 'hidden', + 'autocomplete', + 'spellcheck', + 'translateHint', + 'translateLabel', + 'translate_label', + 'translateDescription', + 'translate_description', + 'size', + 'showon', + 'showonlocal', + ]; $this->default = isset($element['value']) ? (string) $element['value'] : $this->default; From 41f6d2180846917322b3199f45bd123d23f16cf9 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 21 Nov 2024 10:21:26 +0100 Subject: [PATCH 2/9] Update libraries/src/Form/FormField.php Co-authored-by: Harald Leithner --- libraries/src/Form/FormField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index e0f26f9868d72..770d0df5d8aab 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -348,7 +348,7 @@ abstract class FormField implements DatabaseAwareInterface, CurrentUserInterface * Use the global (inherited) field value or local set field value on showon. * * @var boolean - * @since 3.2 + * @since __DEPLOY_VERSION__ */ protected $showonlocal = false; From 55209b1334c9bb7b5cf25c1c4d5be73873aa0363 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 21 Nov 2024 10:21:33 +0100 Subject: [PATCH 3/9] Update libraries/src/Form/FormField.php Co-authored-by: Harald Leithner --- libraries/src/Form/FormField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index 770d0df5d8aab..a2dcd325ce9fd 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -350,7 +350,7 @@ abstract class FormField implements DatabaseAwareInterface, CurrentUserInterface * @var boolean * @since __DEPLOY_VERSION__ */ - protected $showonlocal = false; + protected $showonLocal = false; /** * The parent class of the field From 2dd5ca428df53491c051511db505584af32741e2 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 21 Nov 2024 10:21:46 +0100 Subject: [PATCH 4/9] Update libraries/src/Form/FormField.php Co-authored-by: Harald Leithner --- libraries/src/Form/FormField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index a2dcd325ce9fd..8e46b509dd956 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -574,7 +574,7 @@ public function __set($name, $value) case 'readonly': case 'autofocus': case 'hidden': - case 'showonlocal': + case 'showonLocal': $value = (string) $value; $this->$name = ($value === 'true' || $value === $name || $value === '1'); break; From 6ea77174a3ce087f17194d242e43522461290b7e Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 21 Nov 2024 10:21:56 +0100 Subject: [PATCH 5/9] Update libraries/src/Form/Field/ListField.php Co-authored-by: Harald Leithner --- libraries/src/Form/Field/ListField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Form/Field/ListField.php b/libraries/src/Form/Field/ListField.php index 472a62ba7b730..f79f6511cb09c 100644 --- a/libraries/src/Form/Field/ListField.php +++ b/libraries/src/Form/Field/ListField.php @@ -192,7 +192,7 @@ protected function getOptions() if ($option->value === $value) { $value = $option->text; - if (!$this->showonlocal) { + if (!$this->showonLocal) { $tmp->optionattr = ['data-global-value' => $option->value]; } From 162936482cd4cace2ca5e3db3c790681d9958c31 Mon Sep 17 00:00:00 2001 From: Harald Leithner Date: Thu, 21 Nov 2024 10:57:47 +0100 Subject: [PATCH 6/9] Update libraries/src/Form/Field/ListField.php --- libraries/src/Form/Field/ListField.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/src/Form/Field/ListField.php b/libraries/src/Form/Field/ListField.php index f79f6511cb09c..54343be2361d7 100644 --- a/libraries/src/Form/Field/ListField.php +++ b/libraries/src/Form/Field/ListField.php @@ -135,12 +135,12 @@ protected function getOptions() $selected = ($selected === 'true' || $selected === 'selected' || $selected === '1'); $tmp = [ - 'value' => $value, - 'text' => Text::alt($text, $fieldname), - 'disable' => $disabled, - 'class' => (string) $option['class'], - 'selected' => ($checked || $selected), - 'checked' => ($checked || $selected), + 'value' => $value, + 'text' => Text::alt($text, $fieldname), + 'disable' => $disabled, + 'class' => (string) $option['class'], + 'selected' => ($checked || $selected), + 'checked' => ($checked || $selected), ]; // Set some event handler attributes. But really, should be using unobtrusive js. From a5fdfdf8ef9c834cc0f49c994f31e269f38223ea Mon Sep 17 00:00:00 2001 From: Harald Leithner Date: Thu, 21 Nov 2024 10:57:53 +0100 Subject: [PATCH 7/9] Update libraries/src/Form/FormField.php --- libraries/src/Form/FormField.php | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index 8e46b509dd956..b27dba9f22323 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -666,35 +666,9 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) $this->group = $group; $attributes = [ - 'multiple', - 'name', - 'id', - 'hint', - 'class', - 'description', - 'labelclass', - 'onchange', - 'onclick', - 'validate', - 'pattern', - 'validationtext', - 'default', - 'required', - 'disabled', - 'readonly', - 'autofocus', - 'hidden', - 'autocomplete', - 'spellcheck', - 'translateHint', - 'translateLabel', - 'translate_label', - 'translateDescription', - 'translate_description', - 'size', - 'showon', - 'showonlocal', - ]; + 'multiple', 'name', 'id', 'hint', 'class', 'description', 'labelclass', 'onchange', 'onclick', 'validate', 'pattern', 'validationtext', + 'default', 'required', 'disabled', 'readonly', 'autofocus', 'hidden', 'autocomplete', 'spellcheck', 'translateHint', 'translateLabel', + 'translate_label', 'translateDescription', 'translate_description', 'size', 'showon', ]; $this->default = isset($element['value']) ? (string) $element['value'] : $this->default; From ff091110c6d413d7a93e3febb437b62504bc31d6 Mon Sep 17 00:00:00 2001 From: Harald Leithner Date: Thu, 21 Nov 2024 12:08:34 +0100 Subject: [PATCH 8/9] Update libraries/src/Form/FormField.php --- libraries/src/Form/FormField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index b27dba9f22323..6b3d1f7cea038 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -481,7 +481,7 @@ public function __get($name) case 'spellcheck': case 'validationtext': case 'showon': - case 'showonlocal': + case 'showonLocal': case 'parentclass': return $this->$name; From fab2ef624838b9d10cc09dac317d7d8b6db7304b Mon Sep 17 00:00:00 2001 From: Ruud van Lent Date: Thu, 21 Nov 2024 13:33:13 +0100 Subject: [PATCH 9/9] without formatting --- libraries/src/Form/FormField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index 6b3d1f7cea038..525b1c0a1c517 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -668,7 +668,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) $attributes = [ 'multiple', 'name', 'id', 'hint', 'class', 'description', 'labelclass', 'onchange', 'onclick', 'validate', 'pattern', 'validationtext', 'default', 'required', 'disabled', 'readonly', 'autofocus', 'hidden', 'autocomplete', 'spellcheck', 'translateHint', 'translateLabel', - 'translate_label', 'translateDescription', 'translate_description', 'size', 'showon', ]; + 'translate_label', 'translateDescription', 'translate_description', 'size', 'showon', 'showonLocal', ]; $this->default = isset($element['value']) ? (string) $element['value'] : $this->default;