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.
The D7 field api allows you to position labels either above, inline, or . Webform should have at least those options and perhaps some additional options.
I suggest the following options should be available.
- Above
- Below
- Inline before
- Inline after
- Hidden
Comment | File | Size | Author |
---|---|---|---|
#7 | webform_inline_labels-d6.patch | 9.31 KB | quicksketch |
#7 | webform_inline_labels-d7.patch | 8.88 KB | quicksketch |
#6 | webform_inline_labels-d7.patch | 1.38 KB | quicksketch |
webform_title_display.patch | 3.48 KB | james.elliott | |
Comments
Comment #1
quicksketchThis makes logical sense because we can support better theming in D7 than we had in D6. However I think generally the options for "Below" and "Below Inline" are unnecessary. Webform is meant for end-users not developers for which the full set of options was created. I think these options make the most sense:
- Above
- Inline
- Hidden
We also can't use such advanced CSS as this:
Comment #2
quicksketchComment #3
quicksketchA very-related issue: #255356: Option for putting label and field on same line (inline). I'm not sure which one to close, each takes a different approach. I think it makes more sense for labels to be form-wide when it comes to positioning, but I definitely see the appeal of re-using our existing label option. It puts the option where users expect the option to be, makes it more in-line with Drupal core, and it doesn't add any complexity to our existing code.
Comment #4
james.elliott CreditAttribution: james.elliott commentedIs supporting IE6 a priority for this module? Is that why the CSS you quoted in #1 can't work?
Comment #5
quicksketchYes the Webform project should still support IE6 (even if the Form Builder project does not). Additionally the "+" selector is not fully supported even in IE7 and IE8 (http://www.quirksmode.org/css/contents.html), and I'd prefer to avoid use of it anyway considering it's legibility.
Comment #6
quicksketchHere's the approach I would prefer to take for this issue. Only 3 options will be supported (Inline, Above, Hidden). No option yet but it shows how easy this is to add to our theming, no special CSS required.
Comment #7
quicksketchAfter generalizing this a bit I'm feeling really good about this patch. This patch now does all of the following:
- Provides two new "features" that can be specified in hook_webform_component_info: "title_display" and "title_inline".
- Fields that do not support title display (markup, hidden) have title options omitted entirely.
- Those that support "Inline" display select lists with 3 options for Above, Inline, and Hidden.
- Those that do not support inline (textarea, grid) are shown a checkbox for "Hide title" just like the current options.
- Fixes fieldset title hiding (#1042642: Fieldset Titles Cannot be Hidden).
- Works in both D6 and D7.
I've committed this patch for starters.
Comment #8
quicksketchComment #9
Brainwrap CreditAttribution: Brainwrap commentedWill this patch be applied to a new version of Webform 6.x, or will it only be available as a patch?
Comment #10
quicksketchYes, as it's marked "fixed" it's already included in the 3.x versions (as I said in #7, that's what "committing" means). The 3.10 version (due out soon) will include this functionality.
Comment #11
Brainwrap CreditAttribution: Brainwrap commentedGreat! Sorry about that, still familiarizing myself with some of the development lingo.
Comment #12
quicksketchI actually got out 2 versions (3.10 and 3.11). This functionality is included in 3.11 only, it's available now from the project page.
Comment #13
Brainwrap CreditAttribution: Brainwrap commentedWell, I just installed 3.11 on Drupal 6.20, and I see the new drop-down per-field options (Above, Inline, None), but it isn't working--the label shows up Above the field whether I have Above or Inline selected.
Choosing None does, however, hide the label completely.
Comment #14
quicksketchHave you run update.php since updating? That should clear your caches, though clearing Drupal caches might not also be a bad idea. Since the inline fields require CSS changes, they need to be flushed.
Comment #15
Scott M. Sanders CreditAttribution: Scott M. Sanders commentedSubscribing
Comment #16
Brainwrap CreditAttribution: Brainwrap commentedI had already run update.php, but I had CSS compression turned on at the time. I just tried turning CSS compression off, re-ran update.php; no dice.
Then I tried actually clearing all Drupal caches...nope.
I even tried clearing my browser cache, cookies, history, etc...nope.
HOWEVER, then I tried switching the theme from CTI Flex back to Garland, and voila, it works!
Switching back to CTI Flex kills the in-line layout again, however.
Any suggestions?
Comment #17
quicksketchUse Firebug to determine what CSS in your theme is prevent Webform from displaying the fields inline. Because the theme CSS is always added last, it takes precedence over the CSS added by modules. Something in the theme CSS (probably style.css) is forcing the fields to display as blocks even though Webform is trying to display them inline.
Comment #18
Brainwrap CreditAttribution: Brainwrap commentedBingo! Yep, it turns out that the CTI Flex theme has a specific forms.css file which includes this line:
All I had to do was remove the display: above; bit and it works, thanks!
I also had to tweak the css code a bit to space the fields out. I understand that getting the fields to line up horizontally via the interface would be a pain, but I was able to further customize the forms.css file with the following, which works nicely:
Comment #19
Brainwrap CreditAttribution: Brainwrap commentedHmmm...ok, well, adding the last bit of code has the unfortunate effect of causing EVERY label on EVERY form to shoot out to the right...including all administrative/editing pages, which makes for an awkward layout.
Oh well...it's still much better than it was. Thanks again!
Comment #20
Brainwrap CreditAttribution: Brainwrap commentedAha!
OK, I figured out how to get the labels to line up neatly (right-justified) while the fields are lined up neatly (left-justified) *without* messing up the layout of admin editing pages.
In modules/webform/css/webform.css, just change the following:
...to this:
The tricky part is setting the width to 15em, since the best width for the labels will vary depending on the form (you don't want it sticking out too far, but you also don't want a long label to wrap around to another line).
The 5px top margin keeps the label from displaying slightly higher than the field...not sure if this is a browser-specific thing, but it fixes it for Safari and Firefox on OS X.
Here's an example of what it looks like for me using Webform 3.11, with all fields set to Inline, *and* with the webform.css edit I made above:
http://www.mercy-mhub.net/alumnae_survey
Hope this helps others?
Comment #21
Brainwrap CreditAttribution: Brainwrap commentedOne final note: I discovered that if you include a Photo Upload field using the above edits, it causes the formatting of the next field below it to get messed up in Firefox and IE (because, unlike Safari, which only adds an upload button, FF and IE also display a text field). The only solution I came up with was to make the Photo Upload field the last one in the fieldset.
Comment #22
wavesailor CreditAttribution: wavesailor commentedSubscribing