When using the Bootstrap theme (https://www.drupal.org/project/bootstrap), the file upload field is not displayed on the Import page. See attached.

CommentFileSizeAuthor
#29 file_upload_disappears-2308343-27.patch4.25 KBjurgenhaas
#21 interdiff-2308343-16-21.txt782 bytesmegachriz
#21 feeds-theme-file-upload-2308343-21.patch3.92 KBmegachriz
#21 2308343-21-html.png27.79 KBmegachriz
#21 2308343-core-image-field-html.png35.59 KBmegachriz
#21 2308343-init-bootstrap.png26.82 KBmegachriz
#21 2308343-upload-and-description-grouped-html.png9.84 KBmegachriz
#21 2308343-upload-and-description-not-grouped-html.png29.57 KBmegachriz
#21 2308343-16-bootstrap.png27.24 KBmegachriz
#16 interdiff.txt1.46 KBjoelpittet
#16 2308343-16.patch3.84 KBjoelpittet
#16 User_Importer_after.png14.83 KBjoelpittet
#16 User_Importer.png72.24 KBjoelpittet
#15 2308343-15-other-themes.jpg159.52 KBmegachriz
#15 2308343-15.jpg147.51 KBmegachriz
#15 2308343-11.jpg187.18 KBmegachriz
#15 2308343-current.jpg144.9 KBmegachriz
#15 interdiff-2308343-11-15.txt2.66 KBmegachriz
#15 feeds-theme-file-upload-2308343-15.patch4.19 KBmegachriz
#11 feeds-theme-file-upload-2308343-11.patch2.96 KBtwistor
#11 interdiff.txt851 bytestwistor
#10 2308343-bootstrap-core-file-upload.png31.19 KBmegachriz
#10 2308343-9-bootstrap.png56.98 KBmegachriz
#10 2308343-9-bartik.png67.45 KBmegachriz
#9 feeds-theme-file-upload-2308343-9.patch2.75 KBtwistor
#9 interdiff.txt771 bytestwistor
#7 2308343-6-garland.png59.37 KBmegachriz
#7 2308343-6-bootstrap.png55.66 KBmegachriz
#7 2308343-6-seven.png71.39 KBmegachriz
#7 2308343-6-bartik.png66.39 KBmegachriz
#6 feeds-theme-file-upload-2308343-6.patch2.61 KBtwistor
#2 file_field.png78.39 KBkruser
#1 2308343-feeds-file-import-bootstrap-theme.png26.65 KBmegachriz
feeds_file_import.png39.55 KBkruser

Comments

megachriz’s picture

Status: Active » Postponed (maintainer needs more info)
StatusFileSize
new26.65 KB

It's looking fine with me. I tested in Safari, Opera and Firefox.

Which browser and OS are you using? Have you checked if other file upload fields on your website do work, for example: a file field on a node?

kruser’s picture

StatusFileSize
new78.39 KB

I'm using Win 7 and Chrome. If you look at the console in the screenshot the file upload div is empty. Regular file fields look okay (see attached).

I'm using the 3.x-Dev branch of Bootstrap.

megachriz’s picture

Status: Postponed (maintainer needs more info) » Active

I have reproduced the issue! Once I tried the latest dev of the Bootstrap theme (I tried in 7.x-3.0 previously), the issue was visible in any browser I tried.

Code examination

I have looked through bootstrap's code and I see it is messing a lot with form elements. I then looked at theme_feeds_upload() in feeds.pages.inc where also some weird things seem to happen. The combination of those two causes the issue you have.

Cause of the issue

  • In theme_feeds_upload(), Feeds seems to render the field in a form attribute called #description. This is weird, as this attribute should solely be used as help text for the field.
  • The Bootstrap theme doesn't render the #description attribute, but puts it contents in an other attribute earlier in the process, apparently before theme_feeds_upload() is called.

Conclusion

So both Bootstrap and Feeds do things not right. The Bootstrap theme assumes the contents of #description will not be altered in a theme function (though I have to say it is pretty rare that #description is altered in a theme function) and Feeds abuses #description.

Solution

  1. Find out why Feeds abuses #description.
  2. Rewrite theme_feeds_upload() and make it so that #description does not change.
megachriz’s picture

Title: File upload disappears with Bootstrap Theme » File upload disappears with Bootstrap Theme (abuse of #description in theme_feeds_upload())

I found out that change to #description was made in the following commit (I found this out using git bisect):
http://cgit.drupalcode.org/feeds/commit/?id=a24e15b9ec82ecacef1a4ad43741...

twistor’s picture

Version: 7.x-2.0-alpha8 » 7.x-2.x-dev
Component: Code » User interface
twistor’s picture

Status: Active » Needs review
StatusFileSize
new2.61 KB
megachriz’s picture

StatusFileSize
new66.39 KB
new71.39 KB
new55.66 KB
new59.37 KB

This looks good in all the core themes. It looks less good in the bootstrap theme, but at least the file upload field is shown.

twistor’s picture

I'm open to suggestions.
I just tried to fix the bug and make the intended CSS apply.

Is Bootstrap commonly used as an admin theme?

twistor’s picture

StatusFileSize
new771 bytes
new2.75 KB

Let's see...

megachriz’s picture

StatusFileSize
new67.45 KB
new56.98 KB
new31.19 KB

That was fast!

Patch in #6 is better.

Is Bootstrap commonly used as an admin theme?

I don't know, I hadn't heard of it until I saw this issue. Maybe we shouldn't be too concerned about the Bootstrap theme. It looks better in the Bootstrap theme without the "float: left", but there is no issue with core's file upload field where also a "float: left" is used (though when a file is uploaded using core's file upload field a text field is shown instead of a upload field).

twistor’s picture

StatusFileSize
new851 bytes
new2.96 KB
kruser’s picture

I use Bootstrap as a base theme for frontend only - I usually use Shiny or Seven for admin. The feeds file import page uses the frontend theme.

twistor’s picture

@kruser, Right, that makes sense. In the next version, and current dev version, the import pages use the admin theme.

twistor’s picture

This should still get fixed though, because the current method is totally dumb.

megachriz’s picture

StatusFileSize
new4.19 KB
new2.66 KB
new144.9 KB
new187.18 KB
new147.51 KB
new159.52 KB

I've tested the patch in #11. While it is looking good in Bootstrap theme, it is not in Seven or Bartik on the initial import form (when yet no file is uploaded). See also attached image 2308343-11.jpg. The description of the file upload field seems to be floating to the right.

I've taken a different approach at this:

  • File upload and description belong to eachother, so need to be in a div apart from feeds-file-info.
  • To keep file upload and description together I figured, maybe we should use a theme wrapper instead of a theme function? This means the file upload field is rendered normally, but Feeds wraps the info about the previous uploaded file + the field title around it (see code comments for details).

I've tested the result of my changes in the following themes:

  • Bartik
  • Bootstrap
  • Seven
  • Adaptive theme
  • Garland
  • Pixture reloaded
  • Shiny
  • Stark
  • Zen

Attached are:

  • New patch
  • Interdiff
  • Screenshots of Bartik, Bootstrap, Seven using current dev.
  • Screenshots of Bartik, Bootstrap, Seven using patch from #11.
  • Screenshots of Bartik, Bootstrap, Seven using new patch.
  • Screenshots of other themes using new patch.
joelpittet’s picture

Status: Needs review » Needs work
StatusFileSize
new72.24 KB
new14.83 KB
new3.84 KB
new1.46 KB

This is much better, this also fixes FormTips module https://drupal.org/project/formtips

Although the label is outside of a .form-item div so my admin theme "Adminimal Theme" looks a bit funky.
https://drupal.org/project/adminimal_theme

Doesn't treat it the same as the rest of the form elements.

After this tweak patch:

joelpittet’s picture

Status: Needs work » Needs review

By

This is much better,

I meant

@MegaChriz you rock!

And curious your thoughts on the minor change I made in #16

megachriz’s picture

@joelpittet
Thanks for your compliments! Unfortunately, I have no time to look at this in depth until after DrupalCon. Quick glance, your change seems to make sense.

joelpittet’s picture

@MegaChriz come say hi at DrupalCon, I'll be in the coder's lounge most of the time:)

Håvard’s picture

Thanks for the patch in #16! Works like a charm :)

megachriz’s picture

I looked in depth at the patch in #16 and unfortunately it's still not right :(. This is what it looks like in Bootstrap 7.x-3.1-beta2:

I think the file upload input field and the description div should be grouped together. This is what I intended to do in #15. This is part of the HTML output when using the patch in #16 (using Seven theme):

I tried to group the upload field and description, which initially resulted into this HTML:

But that resulted into the following in Bootstrap 7.x-3.1-beta2:

I then checked the HTML output of the core image upload field and I saw the label is completely seperated from the image preview and the image widget data. So ideally, the "feeds-file-info" and the file upload field should be wrapped inside one div, seperately from the label.

In the attached patch I wrapped the upload input field and the description div in a div called "feeds-file-upload". I also wrapped "feeds-file-info" and "feeds-file-upload" in another div called "feeds-file". This results into the following HTML:

I checked a few themes (Bootstrap, Adminimal, Seven, Bartik, Shiny, Garland), it seems to look well now.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, thanks @MegaChriz that change seems to work great! And nice to meet you in Amsterdam, hopefully you didn't get sick being near me, I was not well for most of it:(

  • twistor committed 87ada15 on 7.x-2.x authored by MegaChriz
    Issue #2308343 by MegaChriz, twistor, joelpittet, kruser: File upload...
twistor’s picture

Status: Reviewed & tested by the community » Fixed

Looks good to me.

I added a bit of a bottom margin to un-crowd things on 7, and check_plain'd the filename.

joelpittet’s picture

Sweet thank:)

Status: Fixed » Closed (fixed)

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

jurgenhaas’s picture

Unfortunately, this fix is not in the alpha-9 release. Any idea why?

megachriz’s picture

@jurgenhaas
See the release notes of 7.x-2.0-alpha9.

jurgenhaas’s picture

StatusFileSize
new4.25 KB

Oh thanks. For the purpose of other users with the same issue I've re-rolled the commit to properly work with the alpha-9 release.

capfive’s picture

the dev version fixed this for me, would be good to roll it into alpha asap as with the current security update things got a little messy but thanks for the patch!