I recently upgrade from 4.7.0->5.1 and I encountered this problem with the upload.module:

button has no properties
http://localhost/misc/drupal.js
Line 31

So JS chokes and nothing works (collapsible formsets, expandable textboxes, etc)

When I disable the module, everything works fine.

CommentFileSizeAuthor
#1 upload.js_.patch655 bytesoadaeh

Comments

oadaeh’s picture

StatusFileSize
new655 bytes

The problem, as I see it, is in upload.js itself. Lines 9 and 10 read:

    // Extract the base name from the id (edit-attach-url -> attach).
    var base = this.id.substring(5, this.id.length - 4);

The problem is that most ids end up looking like this: 'story-node-form-edit-attach-url', which makes $base end up looking like this: '-node-form-edit-attach'.

According to the comment, what $base is supposed to be is 'attach', so this change causes the module to work as expected:

    var base = 'attach';

I'm not sure if that's the correct fix, but it does work, so that's the patch I've created.

This patch is for Drupal 5.x. I'm not yet sure if this behavior is the same in Drupal 6.x. Even though the code is the same, I have not seen the same behavior. As soon as I have more time, I'll do some testing and patch creating, if necessary.

henrrrik’s picture

I had the same problem. The reason that "button" had no properties was that a theme function wiped out the id attribute on the attachment upload input submit tag, rendering it unselectable.

If I understand it correctly, the code you changed uses the id hidden input tag with class="upload" to figure out the base of the id. It then adds "-button" to it to get the id of the input submit tag, e.g:

<input type="submit" name="attach" id="attach-button" value="Attach"  class="form-submit" />
<input type="hidden" name="attach-url" id="edit-attach-url" value="http://mysite.com/upload/js"  class="upload" />

Since this earlier id "edit-attach-url" by default, changing that line in upload.js doesn't affect anything (as long as your setup isn't non-default, that is).

rvavruch’s picture

I tracked down this cause of this problem to the code I found here:

http://drupal.org/node/62647

I think the first snippet of code for phptemplate_button left out .'id="'. $element['#id'].'

oprior’s picture

Priority: Normal » Critical

I wish these fixes had worked for me... Don't ya love sudden module conflicts?!

I've found many other reports complaining of disabled fieldsets, and this had happened to me earlier this year but I had found that time it was related to my page.tpl.php and the new $scripts variable to go in the head.

This time I have no idea what the problem is since the fix from oadaeh above for line 10 of upload.js doesn't fix it. I've tried switching to Garland, so I know it's not my theme. I've tried disabling Pathauto, which has been known to be a culprit of this in the past, but to no avail.

The only way to fix this for me is to disable the Upload module -- but I need it, and I have too much data in there now to switch to another module!!!! There must be something wrong with the code in that module??!

oadaeh’s picture

I had meant to respond here sooner, but I've been swamped. I believe this issue and this issue are related by the same underlying problem, which is duplicate IDs in multiple form fields. As soon as I have some free time, I intend to test it and see if my theory is true.

oprior’s picture

I made a static copy of one the forms in question, validated it, and indeed there are several instances of inputs with double id attributes like:

<input type="submit" name="cck_imagefield_field_upload_high_resolution_im_op" id="edit-upload" value="Upload" id="field_upload_high_resolution_im-attach-button" class="form-submit" />

You think that might have something to do with it?

I should also note that my fieldsets are working when using forms without any Image fields in them -- it must be related to the Image module too eh?

henrrrik’s picture

My problem was also caused by the buggy image button code, make sure you used the revised code: http://drupal.org/node/62647#comment-218932

oprior’s picture

Thanks, I had seen that thread, but I'm not trying to replace the submit buttons -- I tried putting that code in my template.php anyways though but it didn't do anything.

I'm not sure where to go from here... does anyone have any suggestions?

henrrrik’s picture

Switch theme and see if it persists. If not, it's probably something in your template.php.
If that isn't the problem I'd disable contrib modules one by one and see if you can pin it down that way.

oprior’s picture

Thanks for the tip but no, it's not my theme.

When I disable the Upload module my fieldgroups work normally, all the other modules I'm using are necessary to the site. In case you're curious, here is a list of all the modules I have installed.

@ oadaeh, have you had any time to try testing your theory on multiple ids?

henrrrik’s picture

It isn't caused by double id's.

cck imagefield module spits out the extra id, but apart from being invalid HTML it shouldn't cause any problems.

Using Firefox, load the page and check the error console (under Tools). It should tell you why the Javascript doesn't execute properly.

oprior’s picture

Error: button has no properties
Source File: http://www.qualitycraft.com/misc/drupal.js
Line: 31
henrrrik’s picture

Well, it must be one of the modules messing with the id tags. Try disabling them one by one until you find the culprit. If you can narrow it down to a module I might be able to help you debug it.

oadaeh’s picture

@oprior

Try applying the patch in this issue to see if it resolves your problem:
http://drupal.org/node/111719

The patch for Drupal 5.x is in comment #159.

None of the sites I've been working with have been consistent in reproducing this bug, so I have been unable to verify if that patch fixes this problem or not.

jpetso’s picture

Project: upload (simple) » Drupal core
Version: master » 5.6
Component: Code » javascript
Priority: Critical » Normal

I'd say as long as this bug is in a little known contrib module instead of in the update.module issue queue where it belongs, it will get little treatment. It has also been reported to occur in FileField, and I saw it for myself when developing the JavaScript delete buttons (don't remember the context though).

So, this is an issue even if the patch in #1 looks like it's wrong. It would be nice if someone could test if this issue still persists on Drupal 6, and raise the "Version" field accordingly.

jpetso’s picture

Title: Conflict with drupal.js » "button has no properties" error caused by upload.js (wrong field name extraction)

Better title, hopefully.

oadaeh’s picture

jpetso, try applying the patch here: http://drupal.org/node/111719#comment-623069 after you've verified you have the problem and report if it fixes it or not. I'm guessing it will, but I haven't been able to reliably reproduce this bug to test the theory.

jpetso’s picture

I can't test because the error doesn't currently occur on my setup, I just read of it in this filefield issue. I'll ask the reporter to test, though.

chanel’s picture

I installed the patch and it has no effect on the problem. What oadaeh mentions in comment #1 is exactly what I'm seeing with filefield. Upon clicking "Upload" for the second image, various ids are getting truncated: "field-upload-file-attach-button" becomes "-attach-button", "field-upload-file-attach-hide" becomes "-attach-hide".

I've tried switching themes and turning off most modules -- it hasn't had any effect. I'm still trying to track down what's triggering the id malformation.

chanel’s picture

I just did a clean install of 5.6 (because that's the version I'm using where I'm seeing the problem) on a different server and added cck and filefield. The problem does not occur on the clean install. I'll keep paring away on the problematic installation and try to find what's causing the conflict.

chanel’s picture

In terms of installed modules and theme used, both the clean install and "broken" install are the now the same but the problem continues to happen. What appears to be another symptom of the problem is that on the second file upload, the $_POST contains arrays when it should contain strings.

First file upload:

POST: Array
(
    [title] => 
    [parent] => 0
    [nid] => 
    [vid] => 
    [type] => book
    [changed] => 
    [body] => 
    [format] => 1
    [form_token] => e54d711c1967c700f10d6efcb8b10290
    [form_id] => book_node_form
    [field_upload_file-attach-url] => http://server.com/filefield/js
    [cck_filefield_field_upload_file_op] => Upload
    [weight] => 0
    [log] => 
    [comment] => 2
    [menu] => Array
        (
            [title] => 
            [description] => 
            [pid] => 1
            [path] => 
            [weight] => 0
            [mid] => 0
            [type] => 86
        )

    [name] => chanel@yahoo
    [date] => 
    [status] => 1
    [revision] => 1
)

The second file upload looks like this:

POST: Array
(
    [title] => 
    [parent] => 0
    [nid] => Array
        (
            [0] => 
            [1] => 
        )

    [vid] => Array
        (
            [0] => 
            [1] => 
        )

    [type] => Array
        (
            [0] => book
            [1] => book
        )

    [changed] => 
    [body] => 
    [format] => 1
    [form_token] => e54d711c1967c700f10d6efcb8b10290
    [form_id] => book_node_form
    [field_upload_file-attach-url] => Array
        (
            [0] => http://server.com/filefield/js
            [1] => http://server.com/filefield/js
        )

    [field_upload_file] => Array
        (
            [0] => Array
                (
                    [description] => busybar_1.gif
                )

        )

    [cck_filefield_field_upload_file_op] => Upload
    [weight] => 0
    [log] => 
    [comment] => 2
    [menu] => Array
        (
            [title] => 
            [description] => 
            [pid] => 1
            [path] => 
            [weight] => 0
            [mid] => 0
            [type] => 86
        )

    [name] => chanel@yahoo
    [date] => 
    [status] => 1
    [revision] => 1
)

nid, vid, type, and field_upload_file-attach-url shouldn't be arrays. I've got no clue why they are. Any ideas?

chanel’s picture

Good news is that I've finally found what was causing the problem. Bad news is that anyone else that has a similar problem won't have the same cause I did. I use Drupal inside a large company which uses a modified version of PHP -- one of the PHP "features" created arrays when you'd normally expect to get a string. Once I turned off the "feature", the problem went away.

mdroste’s picture

I use the Upload module and autocomplete cck fields. Autocomplete fields don't work anymore.
The only solution I've found, is to remove 'drupal_add_js('upload.js) from the upload.module.

oadaeh’s picture

@mdwp, did you also try applying the patch here: http://drupal.org/node/111719#comment-623069 ?

dpearcefl’s picture

Status: Active » Closed (won't fix)

Considering the time elapsed between now and the last comment plus the fact that D5 is no longer supported, I am closing this ticket.