[BUGFIX] Allow attribute value "0" in EXT:form elements 21/9021/6
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 14 Feb 2012 12:17:20 +0000 (13:17 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 14 Dec 2014 19:42:34 +0000 (20:42 +0100)
If an attribute value of "0" is set in an EXT:form element (e.g.
TEXTLINE) currently the input element in the frontend is rendered with
an empty value "".

Do not check attribute values with empty() to allow "0" values.

Resolves: #31920
Releases: master, 6.2
Change-Id: I624c7da38c23429f68000e085dbd82c23fb7e834
Reviewed-on: http://review.typo3.org/9021
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Stephan Großberndt <stephan@grossberndt.de>
Tested-by: Stephan Großberndt <stephan@grossberndt.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/form/Classes/Domain/Factory/TypoScriptFactory.php
typo3/sysext/form/Classes/View/Confirmation/Element/AbstractElementView.php
typo3/sysext/form/Classes/View/Form/Element/AbstractElementView.php
typo3/sysext/form/Classes/View/Mail/Html/Element/AbstractElementView.php

index 8e780ad..eaae871 100644 (file)
@@ -241,7 +241,7 @@ class TypoScriptFactory implements \TYPO3\CMS\Core\SingletonInterface {
                        $mandatoryAttributes = $element->getMandatoryAttributes();
                        foreach ($attributes as $attribute => $value) {
                                if (isset($arguments[$attribute]) || isset($arguments[$attribute . '.']) || in_array($attribute, $mandatoryAttributes) || !empty($value)) {
-                                       if (!empty($arguments[$attribute])) {
+                                       if ($arguments[$attribute] !== '') {
                                                $value = $arguments[$attribute];
                                        } elseif (!empty($arguments[($attribute . '.')])) {
                                                $value = $arguments[$attribute . '.'];
index b2fef4e..762a415 100644 (file)
@@ -239,7 +239,7 @@ abstract class AbstractElementView {
                foreach ($attributes as $key => $attribute) {
                        if (!empty($attribute)) {
                                $value = $attribute->getValue();
-                               if (!empty($value)) {
+                               if ($value !== '') {
                                        $domElement->setAttribute($key, $value);
                                }
                        }
index a412676..c7f1c65 100644 (file)
@@ -292,7 +292,7 @@ abstract class AbstractElementView {
                foreach ($attributes as $key => $attribute) {
                        if (!empty($attribute)) {
                                $value = htmlspecialchars($attribute->getValue(), ENT_QUOTES);
-                               if (!empty($value)) {
+                               if ($value !== '') {
                                        $domElement->setAttribute($key, $value);
                                }
                        }
@@ -308,7 +308,7 @@ abstract class AbstractElementView {
         */
        public function setAttribute(\DOMElement $domElement, $key) {
                $value = htmlspecialchars($this->model->getAttributeValue((string)$key), ENT_QUOTES);
-               if (!empty($value)) {
+               if ($value !== '') {
                        $domElement->setAttribute($key, $value);
                }
        }
@@ -320,10 +320,11 @@ abstract class AbstractElementView {
         * @param \DOMElement $domElement DOM element of the specific HTML tag
         * @param string $key Key of the attribute which needs to be changed
         * @param string $other Key of the attribute to take the value from
+        * @return void
         */
        public function setAttributeWithValueofOtherAttribute(\DOMElement $domElement, $key, $other) {
                $value = htmlspecialchars($this->model->getAttributeValue((string)$other), ENT_QUOTES);
-               if (!empty($value)) {
+               if ($value !== '') {
                        $domElement->setAttribute($key, $value);
                }
        }
index ede159b..f40ca8f 100644 (file)
@@ -236,7 +236,7 @@ abstract class AbstractElementView {
                foreach ($attributes as $key => $attribute) {
                        if (!empty($attribute)) {
                                $value = htmlspecialchars($attribute->getValue(), ENT_QUOTES);
-                               if (!empty($value)) {
+                               if ($value !== '') {
                                        $domElement->setAttribute($key, $value);
                                }
                        }
@@ -252,7 +252,7 @@ abstract class AbstractElementView {
         */
        public function setAttribute(\DOMElement $domElement, $key) {
                $value = htmlspecialchars($this->model->getAttributeValue((string)$key), ENT_QUOTES);
-               if (!empty($value)) {
+               if ($value !== '') {
                        $domElement->setAttribute($key, $value);
                }
        }
@@ -268,7 +268,7 @@ abstract class AbstractElementView {
         */
        public function setAttributeWithValueofOtherAttribute(\DOMElement $domElement, $key, $other) {
                $value = htmlspecialchars($this->model->getAttributeValue((string)$other), ENT_QUOTES);
-               if (!empty($value)) {
+               if ($value !== '') {
                        $domElement->setAttribute($key, $value);
                }
        }