Opened 15 years ago

Closed 12 years ago

#13385 closed Bug (duplicate)

Wrong behavior for textarea tag render

Reported by: William Grzybowski Owned by: nobody
Component: Forms Version: 1.1
Severity: Normal Keywords: textarea form
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

The Textarea widget is rendering textarea tag like this:

return mark_safe(u'<textarea%s>%s</textarea>' % (flatatt(final_attrs),
                conditional_escape(force_unicode(value))))

However this is not the expected behavior for textarea tag, as from W3C[1] this should be:

<textarea>
first line
</textarea>

So the correct render should be:

return mark_safe(u'<textarea%s>\n%s\n</textarea>' % (flatatt(final_attrs),
                conditional_escape(force_unicode(value))))

[1] http://www.w3.org/TR/html401/interact/forms.html#edef-TEXTAREA

Attachments (4)

textarea.patch (548 bytes ) - added by William Grzybowski 15 years ago.
Textarea render
textarea-trunk.diff (600 bytes ) - added by William Grzybowski 15 years ago.
textarea patch for svn trunk
ticket13385.patch (8.2 KB ) - added by Anssi Kääriäinen 15 years ago.
patch with tests
13385.diff (9.9 KB ) - added by Claude Paroz 13 years ago.
Patch updated to current trunk

Download all attachments as: .zip

Change History (16)

comment:1 by Ramiro Morales, 15 years ago

Description: modified (diff)

(reformatted description)

comment:2 by Russell Keith-Magee, 15 years ago

Resolution: invalid
Status: newclosed

I don't see anything in the reference you provide that requires that there be newlines inside the definition of a TEXTAREA, and I haven't seen any evidence that Django's rendering causes problems in any browers in practice.

comment:3 by William Grzybowski, 15 years ago

Resolution: invalid
Status: closedreopened

Sorry i forgot to mention.

The problem is like this:

  • Write a text using the widget Textarea starting with a newline, like: "\n My text here"
  • Save it
  • Come back to edit the saved the

You will not see the blank line in the start of the textarea

comment:4 by Russell Keith-Magee, 15 years ago

Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Ok. I see what you're driving at now. However, it looks to me like only the first \n is required; if you have the trailing \n, you end up padding your submissions.

Tests are also required.

by William Grzybowski, 15 years ago

Attachment: textarea.patch added

Textarea render

comment:5 by William Grzybowski, 15 years ago

OK.

Patch reworked with heading \n.
Tested ok here, tell me if there is anything else to do, i am new here :)

by William Grzybowski, 15 years ago

Attachment: textarea-trunk.diff added

textarea patch for svn trunk

comment:6 by Gabriel Hurley, 15 years ago

FYI, by "tests are also required" Russell meant a regression test for the test suite (i.e. a unit test/doctest). That's what the "needs tests" checkbox on the ticket is for.

by Anssi Kääriäinen, 15 years ago

Attachment: ticket13385.patch added

patch with tests

comment:7 by Anssi Kääriäinen, 15 years ago

Needs tests: unset
Patch needs improvement: unset

comment:8 by anonymous, 14 years ago

Textarea tag should be rendered with cols="" and rows="" attributes, because it's needed by W3C validation.
I think it is obligate, event if those attributes are to be set to empty value.

comment:9 by Julien Phalip, 14 years ago

Severity: Normal
Type: Bug

comment:10 by patchhammer, 14 years ago

Easy pickings: unset
Patch needs improvement: set

ticket13385.patch fails to apply cleanly on to trunk

by Claude Paroz, 13 years ago

Attachment: 13385.diff added

Patch updated to current trunk

comment:11 by Claude Paroz, 13 years ago

Patch needs improvement: unset
UI/UX: unset

comment:12 by Claude Paroz, 12 years ago

Resolution: duplicate
Status: reopenedclosed

Duplicate of #8627, which has just been fixed.

Note: See TracTickets for help on using tickets.
Back to Top