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.
If you override theme_button() with something like the following snippet, upload buttons will cease working.
function mytheme_button($element) {
// Make sure not to overwrite classes.
if (isset($element['#attributes']['class'])) {
$element['#attributes']['class'] = 'form-'. $element['#button_type'] .' '. $element['#attributes']['class'];
}
else {
$element['#attributes']['class'] = 'form-'. $element['#button_type'];
}
return '<div class="submit-button"><input type="submit" '. (empty($element['#name']) ? '' : 'name="'. $element['#name'] .'" ')
.'id="'. $element['#id'] .'" value="'. check_plain($element['#value']) .'" '. drupal_attributes($element['#attributes']) ." /></div>\n";
}
Looked in filefield.js to find something similar to this on lines 80 and 84:
$enabledFields = $(this).parent().parent().find('input.form-file');
I'm guessing we can change that to use the parents() jQuery function and it'll fix it. Don't have the time right now to roll a patch but will if no one else gets to it first.
Comment | File | Size | Author |
---|---|---|---|
#1 | filefield_button_js.patch | 797 bytes | quicksketch |
Comments
Comment #1
quicksketchOddly I put a conditional in the JS file specifically to prevent this exact problem, but I didn't actually change the logic. :P
This is what it's meant to do. Try it out and let me know if it solves the problem for you.
Comment #2
sammys CreditAttribution: sammys commentedIt's all good. Thanks for the quick patch! How about the other line that uses parent().parent()?
Comment #3
quicksketchUnfortunately the other parent().parent() is much more difficult to remove, since when CCK wraps the div around a group of fields, it doesn't put a class on it at all. It does have an ID, so it's possible we could do something like .parents('div[id*=-field-group-]'), or somehow try to build out the ID based on the file field itself.
Comment #4
quicksketchCommitted.