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.
I noticed that the javascript upload handler "upload_js()" doesn't allow the altering of the generated form. That is because it doesn't call drupal_get_form() but form_build() and form_render() seperately. The attached patch fixes this behavior. As most time in drupal_get_form() is consumed by form_build() and form_render() anyway, this is not a performance issue (according to chx).
Comment | File | Size | Author |
---|---|---|---|
#2 | upload_js_0.patch | 669 bytes | kkaefer |
upload_js.patch | 733 bytes | kkaefer | |
Comments
Comment #1
Steven CreditAttribution: Steven commentedThis patch can't be right. Using drupal_get_form() means a <form> tag is output, along with a hidden form id and another form token. We only want a part of the form.
Comment #2
kkaefer CreditAttribution: kkaefer commentedYou are right. I didn't notice that. Now just the hooks are called.
Comment #3
dopry CreditAttribution: dopry commented+1
Code looks good, and is necessary to getting equivalent interfaces for JS and non-js uploads.
marking as critical bug since it make the interaction between upload/form_alter inconsistent..
Comment #4
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedFor what purpose do we need this?
Comment #5
nedjoThe point, I guess, is that the AJAX-supplied form elements here in theory should be available to be altered, just as other form elements are. The elements that the AJAX functions replace were generated as part of a node form, and so might have been altered (e.g., had additional classes supplied). These will be lost in the AJAX versions unless there is a way to alter them, too.
Worth addressing, but not IMO critical.
Comment #6
chx CreditAttribution: chx commentedI had a patch -- quite simple -- which allowed you to get the altered and built form array, it used a #return_array attribute and if it was set and TRUE, returned just after form_builder call from drupal_get_form. However, it was not accepted and thus was the function node_form_array born. This would come handy here because you are duplicating code.
Comment #7
kkaefer CreditAttribution: kkaefer commentedWell, I actually wrote a module that needs to alter the upload form even after the user has uploaded something via JS. And that's the reason why I discovered this bug/lack of feature at all.
Comment #8
Steven CreditAttribution: Steven commentedCommitted to HEAD. But if we are going to see more AHAH like this in Drupal, we'll need a more generic solution.
Comment #9
(not verified) CreditAttribution: commented