When an image is submitted for upload. OptionWidgets fail to be populated with the respective data. This looks very much like #694444: CCK fields don't work correctly. I have also seen a solution posted in #765024: CCK & Node Gallery Solution so it might seem that one of the form functions needs tweaking? Or could this issue be part of a different module? Any ideas on what might remedy this issue?

CommentFileSizeAuthor
#12 no_ahah.patch6.61 KBjustintime
#7 910450.patch1011 bytesjustintime
upload.jpg31.68 KBx4ct0knife

Comments

x4ct0knife’s picture

Ok so while doing some digging it seems that the function node_gallery_upload_js in node_gallery pages.inc is getting its form from the function modified in #765024: CCK & Node Gallery Solution

$form = node_gallery_edit_images_form($form_state, $cached_form['#node']);

If this is the case data should be populated into the option widgets but it seems to only work on the "Manage Images" tab.

dddave’s picture

Title: CCK Fields in Upload » Some CCK Fields not working on the upload screen
Status: Needs review » Active

This is weird. I remember testing this after the above mentioned issues were fixed and everything worked well (or I did not test it enough).

I tested with extensively and it boils down to select lists, radio button lists and check box lists not being displayed correctly on the upload screen.

x4ct0knife’s picture

Thank you dddave for the validation, I stumbled across this while trying to apply a "mature content" radio selection to user uploaded artwork. A option such as this is crucial before I can display any artwork in a view.

dddave’s picture

Priority: Normal » Major

I check on the original issue again and it seems that nobody really tested this on the upload screen. Given the fact that the main coder on this project (justintime) seems to be swapped by other things and that the focus lies on NG3 anyways I doubt that this issue will be tackled soon. So unless someone can provide a patch or justintime knows the solution in a split second advanced cck fields should not be used on the upload screen. Let's hope NG3 lands soon and in good shape so that we can leave NG2 behind.

Upgrading the priority nevertheless because this is quite a WTF.

justintime’s picture

Actually, this is a fairly serious bug, and warrants a new 2.x release. I'm just wrapping up a big project, and should be able to fix this in the next week or so.

dddave’s picture

Hi Justin,
glad to hear that. This bug should never have slipped in and I am beating myself pretty hard for it. I remember testing this extensivly but as it seems NEVER on the upload screen.

Hope you can find some time for NG soon. Looking forward to a NG3 release. ;)

justintime’s picture

Status: Active » Needs review
StatusFileSize
new1011 bytes

Man, this bug just *has* to be in the only function that I have no friggin' clue what's going on in :). There's all kinds of wierd form voodoo going on in there. My best guess is that the form is getting munged and the #field_info property is being lost between lines 167 and 179 in node_gallery.pages.inc. To see if that's the problem, I have a quick hack that restores it if it's lost.

I don't have my test instance up - can someone test this patch and report back?

dddave’s picture

Status: Needs review » Needs work

Doesn't seem to help.

Tested with:

Nodereference (-)
Text/ Selectlist or Radio buttons(-)
Decimal/ Selectlist (-)
Pollfield (-) -> Label shown but lacks the js magic to open the settings
Integer /Radio Buttons (-)
Those fields are working on the the manage screen though.

Link (+)
Decimal/ text field (+)
Embedded Media Field (+)
Integer /Single On/Off Box (+)
Working even on the upload screen.

justintime’s picture

Well, I have to admit, this one is beyond me. I've worked on it for at least 6 hours and can't figure out how any of this AHAH stuff even works in the first place.

There is some very low-level form hackery going on in node_gallery_upload_js(). This function never calls drupal_get_form(), so drupal_prepare_form() and drupal_process_form() are never called. These two latter functions are what execute the hooks that CCK is looking for to modify the form before it's displayed.

Every time I insert those two functions into node_gallery_upload_js(), the form renders properly (including cck optionwidgets), but the submission of the form blows up.

Someone with some deep knowledge of drupal forms and AHAH may be able to figure it out, but that's unfortunately not me.

dddave’s picture

Sorry to hear that. This won't be an issue for NG3, will it?

If NG3 doesn't have this problem that would be ANOTHER good reason to migrate soon after NG3 stabilizes.

Thx for your effort!

justintime’s picture

No, the AHAH upload form in 2.x is replaced with a plain CCK form or optionally a image_fupload form in 3.x, both of which fully support CCK.

justintime’s picture

Status: Needs work » Needs review
StatusFileSize
new6.61 KB

I should've known better than to doubt the perfectionist in me.

I found some docs on AHAH, and it basically says that we're breaking every best practice in AHAH with the current code. I got to thinking, and realized we don't even need AHAH there, we just need a multistep form. What's more, getting rid of this will get rid of the 'http error 0' messages.

Attached is a patch that will remove the AHAH functions and replace it with a multistep form. CCK OptionWidgets work for me, please review.

dddave’s picture

Woah!

This seems to do the trick. All fields mentioned above in #8 seem to be working now. I am going to try to break this but after a first glance it looks like it is working.

AWESOME!

dddave’s picture

So far, so good.

The only field not working is the pollfield. The settings can now be expanded but when you hit the "more options" button to create additional answers the form breaks. After that the upload cannot be submitted due to call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'node_gallery_upload_form' was given in C:\Users\David\Sites\acquia-drupal-site\acquia-drupal\includes\form.inc in Zeile 376.

That said, the problem might be due to pollfield which is in a very suboptimal state. In my opinion this shouldn't block the patch from getting in. Pollfields on imageuploads aren't that important I guess.

I would appreciate if someone else could test this patch btw...

dbeall’s picture

Seems to be working for me.
I haven't really used any cck fields on the images, just the main gallery content type. Might get into more of that this winter,, but probably will be NG3 though.

justintime’s picture

Status: Needs review » Fixed

That's 3 reviews including mine. Committing.

Status: Fixed » Closed (fixed)
Issue tags: -CCK, -upload

Automatically closed -- issue fixed for 2 weeks with no activity.