Issue Bug Closed

#81050Empty table row is added each time saving a Table CE

Georg Tiefenbrunn 04/27/17, 17:49 updated 10/02/18, 11:01

Description

Steps to reproduce in TYPO3 CMS 8.7 LTS (composer; {nl} = newline):

1) Create a new table CE
2) Add dummy content:

A | B | C
1 | 2 | 3

3) Save.
Content in DB is:

A | B | C
1 | 2 | 3

Content in textarea now is:

A | B | C
1 | 2 | 3
{nl}

3) Save again.
Content in DB is:

A | B | C
1 | 2 | 3
{nl}

Content in textarea now is:

A | B | C
1 | 2 | 3
{nl}
{nl}

This behavior was introduced with 84be5e61 where the working part (see removed part)…

<textarea class="form-control" rows="' . $rows . '" disabled>' . $itemValue . '</textarea>

code was replaced with ..

            $html[] =               '<textarea class="form-control" rows="' . $rows . '" disabled>';
            $html[] =                   htmlspecialchars($itemValue);
            $html[] =               '</textarea>';

… which adds the extra newline character when generating the textarea.

Combining the 3 keys to one fixes this issue:

Index: vendor/typo3/cms/typo3/sysext/backend/Classes/Form/Element/TextTableElement.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- vendor/typo3/cms/typo3/sysext/backend/Classes/Form/Element/TextTableElement.php    (revision )
+++ vendor/typo3/cms/typo3/sysext/backend/Classes/Form/Element/TextTableElement.php    (revision )
@@ -190,9 +190,7 @@
         $html[] =   '<div class="form-control-wrap" style="max-width: ' . $width . 'px">';
         $html[] =       '<div class="form-wizards-wrap">';
         $html[] =           '<div class="form-wizards-element">';
-        $html[] =               '<textarea ' . GeneralUtility::implodeAttributes($attributes, true) . '>';
-        $html[] =                   htmlspecialchars($itemValue);
-        $html[] =               '</textarea>';
+        $html[] =               '<textarea ' . GeneralUtility::implodeAttributes($attributes, true) . '>'. htmlspecialchars($itemValue) . '</textarea>';
         $html[] =           '</div>';
         $html[] =           '<div class="form-wizards-items-aside">';
         $html[] =               '<div class="btn-group">';

Reviews 2