• Resolved tonnaer

    (@tonnaer)


    I’m working on a widget, and I have a textarea where the admin can add captions to the slideshow, one caption per line. If he doesn’t want to add a caption to a certain image, he leaves the line empty.

    This works great, as long as the first line contains a caption. If I want to leave the first line empty, then after saving the widget options in the widget admin panel, that first empty line disappears, and what I wrote on the second line now has become the first line.

    I double checked my code, and I don’t do anything with the textarea content, so my guess is that WP somewhere in the process of saving the widget data in the DB eliminates the empty lines at the beginning. If I’m right, then is there a way of preventing this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Off the wall suggestion: if the captions can contain HTML, try putting in   if the first caption is empty.

    Thread Starter tonnaer

    (@tonnaer)

    Thanks for the suggestion. I tried with a simple space, and that works fine. So for the moment, I’ll put this ‘trick’ in the manual.

    But, I hope that someone can tell me how to prevent WP from trimming leading empty lines from the textarea input. I really don’t understand why it should want to intervene in such a way in the user input.

    Glad you found a solution. The WP wizards work in mysterious ways. Now, please use the dropdown at top right to mark this topic ‘Resolved’.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Losing empty line at beginning of textarea’ is closed to new replies.