Closed (outdated)
Project:
Drupal core
Version:
main
Component:
text.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
21 Jun 2017 at 11:10 UTC
Updated:
2 Sep 2026 at 13:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
larowlan#2594553: Add #maxlength to textarea in Form API is in
Comment #10
NitinLama commentedComment #13
vikashsoni commentedPatch applied successfully in drupal-9.3.x-dev
Thanks for the patch
Comment #14
tstoecklerThe patch changes the actual field schema of text long fields. That is not what this issue is about and I'm not sure it's a good change either. If you want a varchar schema column you can use
TextIteminstead ofTextLongItem. This issue is about actually setting the#maxlengthattribute on the textarea in the textarea widget.Comment #19
smustgrave commentedTriaging my issue queue
And this one may still be valid but agree we shouldn't update the schema, not worth it. So TextItem is not an example.
Comment #20
godotislateAgreed with #14 and #19 that this should only be adding the attribute to the textarea in the widget.
But note that then #3226410: CRLF causes mismatch between JS and form maxlength validation (or #3202631: Add Textarea option to normalize newlines to \n and all the related issues with CRLF) come into play.
Comment #21
smustgrave commentedIf we add to the widget I wonder if we should go one level up to StringAreaTextWidget?
Comment #22
godotislateThinking about this a little more:
A lot of the time when people are entering long formatted text, they are entering it via CKEditor. In which case, I don't know that exposing or setting the maxlength property on the
textareaelement is that useful. Markup counts toward the character limit, and the markup in the editor is largely invisible to the user. There are also contrib solutions like Maxlength that enforce limits within the editor, including JS to track the character count.It might actually make more sense to do it for StringAreaTextWidget, since that is plain text.
Comment #23
smustgrave commentedForgot about Maxlength module. So now wonder if this is needed still? @t stoeckler thoughts?
Comment #24
smustgrave commentedPer #23. If no follow up this could be closed.
Comment #25
smustgrave commentedSince there's been no follow up and there is a contrib module that tackles this lets close out for now. Can always be re-opened.