Hey, when using the bootstrap base theme the submit button is not found because file input elements are themed with a 'button' instead of an input. Also some buttons are wrapped in an additional span element.

Comments

adamsro’s picture

rudiedirkx’s picture

Gimme some HTML, or a working example, or a Fiddle, or something. I'm not a very trusting fella.

adamsro’s picture

Here's a big fat copy paste. Not sure if form-item is the best parent class to look for. form-type-managed-file might be a good one.

<div class="form-type-managed-file form-item-field-privatemsg-file-und-0 form-item form-group">
  <label for="edit-field-privatemsg-file-und-0">Add a new file </label>
 <div class="file-widget form-managed-file clearfix input-group"><input max="999999" multiple="" data-validate="settings" class="form-control form-file" type="file" id="edit-field-privatemsg-file-und-0-upload" name="files[field_privatemsg_file_und_0][]" size="22"><span class="input-group-btn"><button class="i-am-dragdropfile btn btn-default form-submit ajax-processed" id="edit-field-privatemsg-file-und-0-upload-button" name="field_privatemsg_file_und_0_upload_button" value="Upload" type="submit" style="display: none;">Upload</button>
</span></div><input type="hidden" name="field_privatemsg_file[und][0][_weight]" value="0">
<input type="hidden" name="field_privatemsg_file[und][0][fid]" value="0">
<input type="hidden" name="field_privatemsg_file[und][0][display]" value="1">

<p class="help-block">Files must be less than <strong>2 MB</strong>.</p>
</div>
rudiedirkx’s picture

Slightly more readable HTML here.

button[type="submit"] is probably not the best either. Maybe .form-submit... Is that unique enough? Or input[type="submit"], button.form-submit (as combined like that).

I'll use your favorite that still works in Seven. Let me know.

adamsro’s picture

I think [type="submit"] is nice a broad. That'll handle input and button of course. .form-submit should work too. I just tested my patch with Seven and it seems to be working well.

rudiedirkx’s picture

Status: Active » Closed (won't fix)

I've decided not to do this, because it has to work in combination with FileField Sources too (several submit buttons) and also for other themes, so there's too many scenario's.

If you can make a patch that works for every scenario I can make up, I'll include it. I'm focusing on default theming (like Seven and probably most themes).

adamsro’s picture

I found this bit in the autoupload module:

$parent = $(this).closest('.form-item');
...
$('.form-submit[value=' + Drupal.t('Upload') + ']', $parent).mousedown();

I bet that'd work well. I can test and roll a new patch if you'd like.

rudiedirkx’s picture

Status: Closed (won't fix) » Active

The Drupal.t('Upload') is very unreliable.

Maybe DDF can add a data attribute to the relevant submit button somewhere in the widget process functions... I'm sure targeting the correct button is simpler in the back than it is in the front.

I'll look at this later.

rudiedirkx’s picture

Status: Active » Fixed

Alright, I think I've fixed it, but I don't do Bootstrap, so you'll have to try it: http://drupalcode.org/project/dragdropfile.git/commitdiff/d35b41e or use dev.

The config form (admin/config/media/dragdropfile) now has an configurable selector, so you can use whatever works for you. The default selector is also better, so you probably don't even have to change it now.

Let me know.

adamsro’s picture

Yup, its working for me. Seems like a robust solution, Thanks. The lousy aim functionality is a pleasant surprise too.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.