2

In Flask wtform's StringField which handles multiline text input, I could only have a long string of text, even through I need to put in multiple lines. If the original text I pasted in has multiple lines, it became a long one-line string as well.

Pressing enter in the text area (string field) does not create a new line, instead it confirms the input. How can I break up a chunk of text into multiple lines in StringField?

1 Answer 1

6

You can either use the TextAreaField field (from wtforms import TextAreaField), or change the widget for the StringField to a textarea:

from wtforms.widgets import TextArea

my_field = StringField('My Field', widget=TextArea())

In any case, you can also pass rows and cols parameters in your template:

{{ form.my_field(cols=50, rows=10) }}
Sign up to request clarification or add additional context in comments.

1 Comment

for some reason the second method doesn't work, but the first method works well

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.