Form api types of file_managed don't work well with the default bootstrap css.

While the file input has a width of 100%, the upload button.btn drops to the next line and isn't properly cleared by the next form element.

Comments

iaartguy’s picture

settled on the following css line (anywhere) to deal with error messages and whatnot...

.form-managed-file { height: auto!important; }

Haven't found a way to get the upload button on the same line as the file input (which seems to be the standard in a default drupal install). Don't like using the !important tag... but deadlines.

mdobossy’s picture

I ran into the same issue you are seeing. In my case, I am using the webform module. In the webform supplied CSS there is a rule:

.webform-container-inline div, .webform-container-inline div.form-item { display: inline }

This is overriding bootstrap's rule on the .input-group wrapper of:

.input-group {display: table; }

As a quick fix, I specified the id 'edit-submitted-' css with a display: table !important; which did the trick.

joelstein’s picture

Status: Active » Needs review
StatusFileSize
new2.47 KB

Here's a patch which renders a Webform file component exactly like a regular managed file element, with the input field and Upload button as an input group.

markhalliwell’s picture

Component: Miscellaneous » Templates
Status: Needs review » Needs work
Issue tags: -CSS, -forms, -FAPI, -managed file

@joelstein, I don't think this issue is about webform specifically, that should probably be a separate issue (and simply returning the output from bootstrap_file_managed_file, not duplicating the code).

joelstein’s picture

Ah, okay. The code is not exactly the same, because Webform file fields can't have the element ID. But otherwise, it's close. I'll open a new issue and we can tackle it there.

markhalliwell’s picture

Status: Needs work » Postponed (maintainer needs more info)

I'll open a new issue and we can tackle it there.

Was this ever done, i.e. is this still an issue?

joelstein’s picture

Mark, no, I'm sorry, I never created a follow-up issue. But fwiw, I've been using this patch for some time now on 100+ websites, and it works sweetly.

markhalliwell’s picture

Title: file_managed buttons do not display correctly » webform_managed_file buttons do not display correctly
Category: Bug report » Feature request
Status: Postponed (maintainer needs more info) » Needs work

Idk why I said what I did in #4, after looking at the code in #3 again, this actually is specific to webform. No new issue needs to be created.

The code is not exactly the same, because Webform file fields can't have the element ID.

It may not be "exactly" the same, but we can add some custom variable before passing it to bootstrap_file_managed_file() so it knows not to add the ID.

Also, this is technically a feature request since it's supporting a 3rd party contrib module that creates custom elements (instead of using core's).

But fwiw, I've been using this patch for some time now on 100+ websites, and it works sweetly.

Maybe so, but I'd like to get this committed and not leave an open issue. If you could find some time to fix the above patch so what I mentioned above, I'll gladly commit it.

joelstein’s picture

Status: Needs work » Needs review
StatusFileSize
new1.64 KB

Here you go. :)

markhalliwell’s picture

Status: Needs review » Needs work
+++ b/templates/webform/webform-managed-file.func.php
@@ -0,0 +1,27 @@
+  require_once DRUPAL_ROOT . '/' . drupal_get_path('theme', 'bootstrap') . '/templates/file/file-managed-file.func.php';

Please use bootstrap_include() here.

joelstein’s picture

Status: Needs work » Needs review
StatusFileSize
new1.6 KB

Here you go! :)

  • markcarver committed 908e4e5 on 7.x-3.x authored by joelstein
    Issue #2136095 by joelstein: webform_managed_file buttons do not display...
markhalliwell’s picture

Status: Needs review » Fixed
joelstein’s picture

Thanks, friend!

markhalliwell’s picture

Cheers :D

Status: Fixed » Closed (fixed)

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