Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I've just notice that the upload file field return an AJAX error, but the file upload works well. This only affects to the callback function i think.
Does anybody a solution for this?
Thanks.
Comment | File | Size | Author |
---|---|---|---|
#36 | formblock-1167076-36.patch | 556 bytes | jgraham |
#20 | patch_ajax_callbacks_do_not_include_1167076.patch | 309 bytes | tbenice |
#13 | formblock.zip | 1.65 KB | rawrzors |
Comments
Comment #1
rogical CreditAttribution: rogical commented+1
Comment #2
jide CreditAttribution: jide commentedHad the same issue. This is because the "node.pages.inc" include file is not included in the AJAX callback (but I have no clue why for the moment). The issue will probably raise with other ajax callbacks.
As a quick and simple fix, you can do this in a custom module (or in the formblock module itself) :
For a real fix, the formblock module should probably do something like traversing all form elements, looking for the '#ajax' property and use a custom callback that includes the needed file. But that may be a little overwhelming, so this simple fix may be enough.
Renaming the issue and bumping as major since this can potentially break the form entirely.
Comment #3
bryancasler CreditAttribution: bryancasler commentedsubscribe
Comment #4
breckenr CreditAttribution: breckenr commented+1
Comment #5
boringtao CreditAttribution: boringtao commentedthe same issue occurs when upload images on register form too. any idea how to fix it?
Comment #6
rawrzors CreditAttribution: rawrzors commentedCould you please elaborate on this fix? When you say "or in the formblock module itself," which file do you mean?
Comment #7
jide CreditAttribution: jide commentedI mean in formblock.module.
Comment #8
rawrzors CreditAttribution: rawrzors commentedI'm sorry to trouble you, but I do not know too much about editing modules.
I have tried to copy & paste the code you provided in the end of the formblock.module, but it causes a parse error on my site. Could you please explain in a bit more detail what to do?
Thank you for your time.
Comment #9
jide CreditAttribution: jide commentedDo not include
, and replace "MYMODULE" with "formblock".
Comment #10
rawrzors CreditAttribution: rawrzors commentedI did as you instructed and only part of the error went away.
Here is a screenshot:
http://img192.imageshack.us/img192/273/errorzw.png
Error occurs when I press upload.
Not sure if I should create a new topic for this part.
Comment #11
jide CreditAttribution: jide commentedPut exactly this at the end of formblock.module :
Comment #12
jide CreditAttribution: jide commentedAh, and clear the cache after that !
Comment #13
rawrzors CreditAttribution: rawrzors commentedJide,
I have followed your instructions and I am still having the problem.
I have attached my formblock.module, if you have some free time, could you please look at it?
Thank you.
Comment #14
jide CreditAttribution: jide commentedThat's odd, it works for me... Anyway, this issue deserves a real fix, I may have a solution that I will post when I get some time.
Comment #15
mikey_p CreditAttribution: mikey_p commentedI'll see if I can find an appropriate fix for this soon, but the problem doesn't appear to be with formblock module (the form should be using $form_state['build_info']['files']['form'] if it needs a specific file).
Comment #16
mikey_p CreditAttribution: mikey_p commentedI'm fairly sure this is really a core bug, see #1271234: Forms in include files should use $form_state['build_info']['files']
Comment #17
sunform_load_include() is your friend, but is only needed in case the form doesn't reside in the 'file' specified in the menu router definition of the current/initial request.
(which seems to be the case here)
(lastly, no patch here? » active)
Comment #18
jide CreditAttribution: jide commented@sun: So if we use a custom path instead of system/ajax, with a callback directly inside the module file, will the needed include files be included ? I believe I saw something like that in media.module.
Comment #19
sunThe AJAX callback menu path is too late. The include file of a form needs to be cached with the form on the page the form appears in the first place.
E.g., you have the node form as a block on the front page. The front page does not load node.pages.inc normally. To build and render this form, you have to include node.pages.inc. This file inclusion needs to be recorded in $form_state when the form is built.
Only that way, a potential AJAX request triggered by a form interaction is going to hit system/ajax (!= front page), which loads the $form_state from cache_form (by form_build_id), checks whether any include files are recorded in $form_state, and if so loads them, and lastly, processes the input and rebuilds the form. (All of this is built-into system/ajax, nothing you'd have to implement yourself.)
So it's really about registering the needed include file only. Normally, that node form would be loaded on node/add/type, and that menu router item defines node.pages.inc as include file. The Form/AJAX system automatically takes over that include file definition from the menu router item to simplify the DX in 90% of all cases.
Lastly, kinda off-topic for this issue, but I wanted to note that you'll have to disable block caching for these blocks - as otherwise, the cached form possibly expires earlier than the cached block, and many other unexpected hiccups.
Comment #20
tbenice CreditAttribution: tbenice commentedpatch that works for me...
Comment #21
rawrzors CreditAttribution: rawrzors commentedtbenice,
I have tried your patch, but the problem still remains.
Anyone know of a similar module that I can use?
Thanks.
Comment #22
jpfeifer CreditAttribution: jpfeifer commentedsubscribe
Comment #23
jpfeifer CreditAttribution: jpfeifer commentedStrange finding. I've tried all the patches and notice that when I clear all caches under admin/config/development/performance, I can upload one image. Any subsequent tries give me the same error.
Is there any other module like this or fix?
J
Comment #24
ansbar CreditAttribution: ansbar commentedAs jpfeifer said, have tried all patches and fixes, non work.
FYI my problem occur when clicking the "upload"-button on a add-node-form.
Error:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'node_form' was given i drupal_retrieve_form()
Would really appreciate if anyone could figure out a working fix ;)
Comment #25
sahaj CreditAttribution: sahaj commentedHad the same problem, but with the country selection inside an 'Address field'. Fix #11 solved it.
Comment #26
jisuo CreditAttribution: jisuo commentedI tried both #11 and #20, but the ajax uploading of images still won't work.
Comment #27
jide CreditAttribution: jide commentedTry this :
Comment #28
jisuo CreditAttribution: jisuo commentedYep, #27 worked. :) Nice job.
Comment #29
jurasjo CreditAttribution: jurasjo commented@jide ROCKS !!!!!!!!! #27 worksssssss
Comment #30
jide CreditAttribution: jide commentedHehe, thanks :)
The bug should be corrected following @sun advices though (although we should find a more generic way to include all needed files like those needed for file upload e.g.).
Comment #31
DanChadwick CreditAttribution: DanChadwick commented#27 worked for my very general way: all I have is a file field added to regular user-defined content type. I'm *not* using Form Block. The bug occurs when adding a new node of that content type and trying to upload. Save the node without uploading, and for some reason you can edit the node and upload even without #27.
(Note, the node is being created from a custom menu item, which I think is the source of the issue.)
Thanks much, but it seems this is a pretty general issue between the core field field upload ajax and the node form.
Comment #32
chikeThanks jide, #27 worked. It's a great relief.
Comment #33
thomasreid CreditAttribution: thomasreid commentedI had this problem so I used jide's solution in #27. The file now uploads when one clicks "Upload" but when you submit the form now, a custom submit handler I have does not get called. The submit handler does get called though if you select a file but don't click "Upload." I believe this is related to the AJAX callback so any solution?
Comment #34
jdflorez CreditAttribution: jdflorez commented#27 works just perfect for me: I'm loading a form block in a lightbox for anonymous users to create content and works just fine.
Thanks jide.
Comment #35
peem83 CreditAttribution: peem83 commentedunfortunetely #27 does not work if you have formblock on another node add/edit page which contain file field, any ideas how to solve that ?
Comment #36
jgraham CreditAttribution: jgraham commentedAttached patch addresses the issue by calling form_load_include() in the event that we have a node form without the necessary 'modules/node/node.pages.inc' already included following sun's recommended approach in 17/19.
Comment #37
cjgriffin CreditAttribution: cjgriffin commented#36 worked for me, with a node form on the Dashboard. Thanks jgraham!
Comment #38
deadtech@gmail.com CreditAttribution: deadtech@gmail.com commented#36 worked! thanks.
Comment #39
kreatIL CreditAttribution: kreatIL commented#36 worked for me, with Adress field. Thx.
Comment #40
rickharington CreditAttribution: rickharington commented@jdflorez can you pleassde tellme how you got a form block in a lughtbox, it's exactly what I'm looking for.
Comment #41
jon_skilling@hotmail.com CreditAttribution: jon_skilling@hotmail.com commentedThanks for this. Worked perfectly!
Comment #42
Peter Majmesku#27 works for me, too. how about patching the dev-version with this?
Comment #43
mikey_p CreditAttribution: mikey_p commentedCommitted to 7.x-1.x.
Comment #45
jbrauer CreditAttribution: jbrauer commentedComment #46
ishwar CreditAttribution: ishwar commentedCorrect ...
#27 is working for me.