Looking for a problem I am having with Maxlength, and was thinking that others might possibly have the same problem.

The maxlength counter is not displayed under the body textarea on the node/add page to create a new node, however it IS displayed on the node/edit page when editing an existing node. The maxlength constraint still works. (if you submit a node form that exceeds the given max length it gives you an error and displays the form, now with the counter.) This isn't the desired behavior, is it? It seems to me that my form on the node/add just isn't being given the

. Also, the javascript link was not being put into the head of these pages. (I hard coded them in, which of course does nothing without the correct elements.)

Could it be the 'theme' function ?

function theme_maxlength_textarea($element) {
  $prefix = '';
  
  if ($element['#name'] == 'body') { .....

I noticed my form doesn't seem to have a #name element, looks like this:

 [body] => Array
                (
                    [#type] => textarea
                    [#title] => Message
                    [#default_value] => 
                    [#rows] => 20
                    [#required] => 
                )

I haven't used form_alter or anything that I can think of that would change the standard node form. Any ideas?

Comments

ericpugh’s picture

oops..
I meant to say that the textarea isn't being wrap in:

<div id="maxlength-cournter">
mariuss’s picture

Assigned: Unassigned » mariuss
Status: Active » Postponed (maintainer needs more info)

Is this a custom content type? What did you use to create it?

Can you do a quick test and apply maxlength to story or page, just to see if it works for those?

ericpugh’s picture

Hi thanks for a response. Yes I am using custom content types (CCK) containing text fields, date, and Imagefield. I also tried it with the default page and blog content types. (still no max counter)
It won't post if you exceed the given max length, so something is working right. I'm trying to find out what is interfering. I disabled most other modules, that might be the cause. (like "form filter") Here is my javascript being loaded.

 <script type="text/javascript" src="/misc/jquery.js"></script>
<script type="text/javascript" src="/misc/drupal.js"></script>
<script type="text/javascript" src="/modules/jquery_update/compat-1.0.js"></script>
<script type="text/javascript" src="/misc/autocomplete.js"></script>
<script type="text/javascript" src="/misc/collapse.js"></script>
<script type="text/javascript" src="/misc/progress.js"></script>
<script type="text/javascript" src="/sites/all/modules/jstools/jstools.js"></script>
<script type="text/javascript" src="/sites/all/modules/jstools/activeedit/activeedit.js"></script>
<script type="text/javascript" src="/modules/jquery_update/collapse-fix.js"></script>
 <script type="text/javascript" src="/modules/maxlength/maxlength.js"></script>

I've installed maxlength on a clean install, created a similar content type, and it worked perfectly! I'll have to keep digging. Of course, I'll post here what I come up with, possibly help someone else.

ericpugh’s picture

Title: Maxlength Counter is not applied to node/add/ContentType » I had an underscore in the name of the content type
Status: Postponed (maintainer needs more info) » Closed (fixed)

Arrgh! Figured it out. I had two similar CCK content types one had an image upload, and the other didn't, so I named them message_image and message_text. Removed the underscore, and now it works. (another aarrgh!)

Drupal does allow underscores for content type names, but I'm guessing that what's happening is that drupal changes underscores into dashes in the URL and maxlength collects this as $type from arg(2). Which later creates an incorrect value for $form_id. ...umm I think?.
thx

mcurry’s picture

subscribe