I'm having some problems where using drupal_get_form() breaks the upload/remove functionality of a file field when it's processed with ajax. It seems this may be a core issue (http://drupal.org/node/1526300) but I haven't found a solution that works for me yet.

I've noticed that the form degrades gracefully when ajax is disabled in the browser and the file field works correctly.

I would like to just disable ajax for this form but I don't see how. I don't see any #ajax elements in hook_form_alter() or hook_field_widget_form_alter().

1 Answer 1


You can force the buttons to submit normally by unbinding the javascript events using something like this in a form alter:

// Disable ajax upload for file field
drupal_add_js("jQuery(function() { jQuery('#edit-field-image :submit').unbind(); });", 'inline');

It would be nice if there was a way to not have the javascript bound in the first place by manipulating the $form (or something else).

  • Excellent workaround, allowing to solve temporarily some broken AJAX stuff. Saved my day. Would upvote five times if possible.
    – Countzero
    Commented Jan 27, 2013 at 8:17
  • Awesome. It helped me solve the error "An illegal choice has been detected. Please contact the site administrator." while I was using Translated Entity Reference module. Thanks!
    – Roger
    Commented Aug 30, 2016 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.