Posted by sammys on April 27, 2009 at 1:53am
3 followers
| Project: | FileField |
| Version: | 6.x-3.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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.
Comments
#1
Oddly 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.
#2
It's all good. Thanks for the quick patch! How about the other line that uses parent().parent()?
#3
Unfortunately 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.
#4
Committed.
#5
Automatically closed -- issue fixed for 2 weeks with no activity.