From 0292c7ebadb42b7c145be48682137159481f191d Mon Sep 17 00:00:00 2001 From: Patric Eckhart Date: Mon, 19 Sep 2022 13:42:36 +0200 Subject: [PATCH 1/3] First check if it is an object to avoid problems with DateTime --- Classes/ViewHelpers/RenderValuesViewHelper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/ViewHelpers/RenderValuesViewHelper.php b/Classes/ViewHelpers/RenderValuesViewHelper.php index 7bb9462..64e4014 100644 --- a/Classes/ViewHelpers/RenderValuesViewHelper.php +++ b/Classes/ViewHelpers/RenderValuesViewHelper.php @@ -97,6 +97,9 @@ public function render(): string protected function processElementValue(FormElementInterface $element, $value) { $properties = $element->getProperties(); + if (is_object($value)) { + return $this->processObject($element, $value); + } if (isset($properties['options']) && is_array($properties['options'])) { if (is_array($value)) { return $this->mapValuesToOptions($value, $properties['options']); @@ -104,9 +107,6 @@ protected function processElementValue(FormElementInterface $element, $value) return $this->mapValueToOption($value, $properties['options']); } - if (is_object($value)) { - return $this->processObject($element, $value); - } return $value; } From 54960311f8bed4f75f6129137d35b95f42b4c311 Mon Sep 17 00:00:00 2001 From: Bastian Waidelich Date: Mon, 19 Sep 2022 17:50:51 +0200 Subject: [PATCH 2/3] Update RenderValuesViewHelper.php --- Classes/ViewHelpers/RenderValuesViewHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/ViewHelpers/RenderValuesViewHelper.php b/Classes/ViewHelpers/RenderValuesViewHelper.php index 64e4014..c25675c 100644 --- a/Classes/ViewHelpers/RenderValuesViewHelper.php +++ b/Classes/ViewHelpers/RenderValuesViewHelper.php @@ -151,14 +151,14 @@ protected function mapValueToOption($value, array $options): string protected function processObject(FormElementInterface $element, $object): string { $properties = $element->getProperties(); - if ($object instanceof \DateTime) { + if ($object instanceof \DateTimeInterface) { if (isset($properties['dateFormat'])) { $dateFormat = $properties['dateFormat']; if (isset($properties['displayTimeSelector']) && $properties['displayTimeSelector'] === true) { $dateFormat .= ' H:i'; } } else { - $dateFormat = \DateTime::W3C; + $dateFormat = \DateTimeInterface::W3C; } return $object->format($dateFormat); } From 9c13aea0495e7715b6c0077a43a4165557666d7e Mon Sep 17 00:00:00 2001 From: Bastian Waidelich Date: Mon, 19 Sep 2022 17:51:34 +0200 Subject: [PATCH 3/3] Update RenderValuesViewHelper.php --- Classes/ViewHelpers/RenderValuesViewHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/ViewHelpers/RenderValuesViewHelper.php b/Classes/ViewHelpers/RenderValuesViewHelper.php index c25675c..7dabda2 100644 --- a/Classes/ViewHelpers/RenderValuesViewHelper.php +++ b/Classes/ViewHelpers/RenderValuesViewHelper.php @@ -96,10 +96,10 @@ public function render(): string */ protected function processElementValue(FormElementInterface $element, $value) { - $properties = $element->getProperties(); if (is_object($value)) { return $this->processObject($element, $value); } + $properties = $element->getProperties(); if (isset($properties['options']) && is_array($properties['options'])) { if (is_array($value)) { return $this->mapValuesToOptions($value, $properties['options']);