Issue Bug Closed

#94516<textarea> is losing empty lines on the beginning

Albrecht Köhnlein 07/09/21, 09:27 updated 12/02/25, 14:33

Description

I had a case where I had to enter some text starting with multiple empty lines into FormEngine’s textarea element.

When saving and re-opening the first empty line was missing in the editor. I investigated a little bit and found out, that the empty lines still exist when the data is saved to database and still exist in the rendered HTML when generating the form. But there seems to be any JavaScript which removes the first line.

This problem can be reproduced, if you enter some empty lines + a line of text in field tt_content.rowDescription or any other textarea.

When saving and reopening the form, you will see, there is one less empty line in the editor.

Reviews 2

Files 3

History 717

  1. Torben Hansen commented <span data-processor="relativetime" data-value="2021-07-27T18:38:59+00:00" > 07/27/21, 18:38 </span>

    Pretty interesting bug. I observed the same bug in the PHP project “adminer” while trying to reproduce the problem. Actually, data gets written correct into the database and all new lines are preserved. When the saved data is used in a HTML textarea tag, it seems to be important to actually render the textarea with the data as following (simplified):

    '<textarea>' . LF . 
    $multiLineData .
    '</textarea>'

    It seems important to add a linefeed after the opening textarea tag.

    The FormEngine Element TextElement actually renders the textarea as shown below:

    '<textarea>' . $multiLineData . '</textarea>'

    This leads to the described behavior when saving the record. I changed this locally as shown in the first example and then all new lines are shown correctly.

  2. Riccardo De Contardi commented and changed attached clipboard-202305131217-sroxg.png attached clipboard-202305131219-ebmoa.png <span data-processor="relativetime" data-value="2023-05-13T10:20:06+00:00" > 05/13/23, 10:20 </span>

    This issue is still present on TYPO3 13.0.0-dev

    Steps to reproduce it

    1. Open a page
    2. Edit the field “Notes > Description” ([rowDescription]) with the following:
    - Leave 3 lines empty (hit 3 times carriage return) and then write something: you should see this:

    clipboard-202305131217-sroxg.png

    3. Save it

    Result:

    One empty line is cut off:

    clipboard-202305131219-ebmoa.png

    Expected result

    the field content should remain the same

  3. Riccardo De Contardi commented <span data-processor="relativetime" data-value="2024-07-05T14:55:36+00:00" > 07/05/24, 14:55 </span>

    This issue is still present on 13.3.0-dev (latest main)

  4. Albrecht Köhnlein commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2025-01-07T08:35:08+00:00" > 01/07/25, 08:35 </span>

    Applied in changeset commit:57b5c6b44449c612e5d3af091d53bdb4d833cd1f.