Funny: I need this exact sort of feature for a site I'm working on, but need it for a bunch of CCK fields, not just the Body. It would seem relatively simple to extend this to Titles and/or CCK textfields/textareas, at the expense of a more complex administration screen.
Comments
Comment #1
mariuss commentedVery good suggestions.
I broke the title related one out into a separate issue, I will probably work on that first.
See: Set maxlength for title field as well.
Comment #2
mariuss commentedI was thinking some more about this. The easiest way to implement, and to use, seems to implement an alternate textarea widget for text field types.
An option would to create a feature request on the CCK module, but then they would have to rewrite the javascript used here. Probably it is simpler to just write a widget.
Comment #3
phildu commentedi'mrealy interest for cck or sms oe all text area
Comment #4
kriskd commentedAdding a comment in order to subscribe. I would like to see maxlength available to CCK fields as well. Thanks!
Comment #5
Patrick Nelson commentedI would like to see this feature too and am subscribing to catch updates
Comment #6
droople commentedmax length for cck as well
thanks
Comment #7
tj2653 commented+1 for cck fields
Comment #8
encho commentedMe too. Also would be nice to see it on any other field. Like ie excerpt module (custom teaser field).
Comment #9
NaX commentedI need this for CCK text fields. My text fields where all textareas (rows > 1) and were not set to multiple.
Please note I am not accounting for normal text input fields or fields set to multiple. To make this really useful a checkbox should be added to the text field settings widget. I don’t know how possible that is with CCK. I have never tried to added settings to CCK field.
I could have put this in separate mini module instead of hacking maxlength.
I hacked my form_alter like this.
And In my theme I added this to override theme_maxlength_textarea()
Hope it helps.
Comment #10
mariuss commentedThanks NaX, but I don't think I will go with this approach. As you mention, it still needs work, and I don't think it is the right solution.
As I mentioned in comment #2, the right solution is to implement an alternate textarea widget. This way you can select the widget only when you need it and specify the maximum length individually.
Comment #11
NaX commentedI personally think the most flexible approach is to uses a similar method to the one used by the formfilter module. That will allow for Maxlength to be added to almost any text and textarea fields on any form.
Comment #12
mariuss commentedThe problem, as I see it, is that you really don't want to apply this to every single textarea and also where you apply it you need specific configuration (you probably don't want to enforce the same max length on all textareas).
So, altering forms and appending the max length control to them is not too hard. But providing an interface where all possible forms and textareas are listed, so they can be configured individually, is not that easy. Would be something similar to what the captcha module does. It collects forms as you use the site. While this is doable, it is a total overkill imo.
Comment #13
NaX commentedThe captcha interface is very similar to the formfilter interface, the difference is that the formfilter module is doing 90% of what Maxlength length would need to do to implement my idea. When you enable the UI it places a link at the bottom of every form and when you click that link you are present with the same form fields just with a checkbox under each field that says hide. You then select each field you want to hide and submit the form and then that form field is hidden and converted into a forms api value. So most of the code need to implement this is already their.
Some extra coding would need to be done to integrate CCK fields max length values maybe as defaults to the interface, but this is very feasible. It would mean sort of a rewrite and it would turn a small module into a far more complex module.
Just an idea.
Thanks for a useful module.
Comment #14
mariuss commentedLooked at the formfilter project. You can probably go down that road, but I really think it is an overkill in this case.
If there was a CCK widget, together with the existing application to body fields of all nodes, would that solve your problem?
Comment #15
a_c_m commentedThis functionality is now available in the 2.x release, please all have a play with the beta and report back :)
Comment #16
henrijs.seso commented+1 for widget! widget FTW! :)
Comment #17
vanauslo commentedsubscribed
Comment #18
simon georges commentedThis version of Maxlength is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.