I'm sure this is possible and probably even easy but I can't figure out how to do it.
I simply want the description to show up above the drop down listbox. As is, it shows the listbox and then describes what you are selecting. I've tried to figure out the theming capabilities but I never got anywhere. What I would like is to just know where in the code I can make this change because any form I make would be required to be displayed this way. It seems like this would be easier than overriding the defaults with a theme.
Either way though, I need a simple solution. I saw someone ask something similar to this a while ago in a support request and the only answer given was something like "you need to read theming.txt" Well, I've read that and I came up with nothing. Thanks very much for any help!
This would be a nice interface feature, by the way: just having an option of whether the description goes above or below the field.
Comment | File | Size | Author |
---|---|---|---|
#40 | webform_description-above-284431-40.patch | 8.08 KB | DanChadwick |
#36 | webform-description-above-284431-30.patch | 2.3 KB | matthewhilbert |
#29 | webform-description-above-284431-29.patch | 4.34 KB | paramnida |
Comments
Comment #1
poggle CreditAttribution: poggle commentedI've the same query for 5.x-2.1.1
Not really an issue as such, more cosmetics giving subjects the opportunity to read what they're selecting above is nicer - especially if there are many differing options :-)
Comment #2
butler360 CreditAttribution: butler360 commentedDid you ever figure out how to do it?
Comment #3
dmweyer CreditAttribution: dmweyer commentedseems to be quite a few people who are wanting to know how to do this.
Comment #4
dmweyer CreditAttribution: dmweyer commentednot yet, tried to apply suggestion posted, but it broke my webform, so at this stage still in same boat.
Comment #5
butler360 CreditAttribution: butler360 commentedI still haven't figured out how to do this. It'd be nice to get an acknowledgement about this, but I'm sure the module maintainer/creator is busy.
But one thing seems clear to me: there is a lot of demand to be able to change the layout and visuals of the form, whether it's putting the questions and fields inline, removing a colon, changing the width of the fields, or the issue in this post. So seeing some of that implemented in the GUI would be great.
Comment #6
quicksketchHeh, webform is hobby, not a job. I haven't even used Webform in *years*. So requests to improve the GUI will have to come with patches if they're ever going to be added.
Regarding putting a description above the select list, a quick fix is to use a markup field and place it above the select list.
Comment #7
butler360 CreditAttribution: butler360 commentedYes, I figured that was the case. Although, in fairness, I did see you lamenting the fact that Webform wasn't used in the lastest Drupal survey. Others responded that it was missing the necessary features to do so. But this is free work you are doing, so I'm not complaining!
As for the markup field, how would I put that content between the field title and the field? I see that I can put it above it or below it, but not in-between.
Thanks for the response!
Comment #8
Dennis Cohn CreditAttribution: Dennis Cohn commentedAny update? I need my discription above the input field!
How can we do this?
Comment #9
Dane Powell CreditAttribution: Dane Powell commentedI'm still looking for this option too, on any field (not just select fields).
Comment #10
Dane Powell CreditAttribution: Dane Powell commentedComment #11
Dane Powell CreditAttribution: Dane Powell commentedI inserted the following code snippet (from mmilo at http://drupal.org/node/178247) into my theme's template.php to achieve this effect throughout my site. There has to be a way to implement it on a per-module or per-field basis, but I don't have time to delve into that right now unfortunately.
Obviously you'll have to replace pixture_reloaded with your own theme name. Don't forget to flush your cache if this doesn't work at first.
Comment #12
Dane Powell CreditAttribution: Dane Powell commentedUpon further inspection I believe that this is a matter that should be dealt with by themes, not by individual modules, because it's a problem that transcends Webform and really applies to form fields generated by all sorts of modules, both contrib and core.
I have revised my solution, originally given above, to be somewhat more intuitive - see #557162: Position field descriptions more intelligently. Also, for discussion on why this should be implemented at the theme level, see #314385: Make position of #description configurable via the API.
If anyone with more experience has a dissenting view, I'd love to hear it - but since quicksketch has already expressed disinterest in this I'm going to take the liberty of marking this won't fix.
Comment #13
pyxio CreditAttribution: pyxio commentedThank you for this helpful code snippet, Dane. It;s much appreciated! Kevin
Comment #14
mautumn CreditAttribution: mautumn commentedThanks for this patch Dane. I believe this is a much better UE (User Experience). The description qualifies or adds more detail to the question/form label, and it just strikes me as common sense, more intuitive to put this directly below the question/form label.
The reductio ad absurdum of the current default - of putting the description below the field/s - is where the list of options or size of the field is more than will fit in the available displayed form space: the user will not even see the description before filling in that part on the form...
It would be great if there was a global site preference for this, with the default of having the description directly under the label/title and above the field/s, as stated in this issue.
Comment #15
rumblewand CreditAttribution: rumblewand commentedMade to work for drupal 7 with the code in the template.php
I changed it a bit to get my webform descriptions above the input field for drupal 7. Drupal 7 allows you to just make calls just to webform itself.
You will of course change the name "danland" to whatever theme you are using.
Comment #16
RobW CreditAttribution: RobW commentedTo make this an across the board change, would you use theme_form_element() instead? My use case is field descriptions on the node edit pages in an admin theme.
Comment #17
rumblewand CreditAttribution: rumblewand commentedThat is correct. Originally that is what I had it set to but I just needed it for webform. It has also since been pointed out to me that this recalls most of the form function and it could be written just to call the parts needed.
It may not matter in your case but I was also using webform conditional module (allows same page conditionals) and this function was overriding my ability to hide fields since it recalled so much of the original form function. It was since rewritten and is listed in the webform conditional module issue thread.
Comment #18
RobW CreditAttribution: RobW commentedThanks for your reply, especially the extra info, Rumblewand. It'll definitely help me end some errors before they start.
Comment #19
robaminima CreditAttribution: robaminima commentedhi Rumblewand. Thanks for the snippet. It works for me.
Comment #20
kthullUnfortunately #15 doesn't play well with the Webform Conditionals (http://drupal.org/project/webform_conditional) module for showing same-page conditional questions.
All my conditionals are now exposed. I'll have to dig in and see if I can figure that out.
Comment #21
chaz1975 CreditAttribution: chaz1975 commentedThanks again to Rumblewand for the code snippet. Works fine for me too.
Comment #22
MrDeanSmith CreditAttribution: MrDeanSmith commentedWorks perfect, thanks!
Comment #23
bjmiller121 CreditAttribution: bjmiller121 commentedHere's a quick D7 patch to add a checkbox to the field component settings page to place the description above the field. I only tested it on some basic forms and only with the label above. Won't play nicely with inline labels, but you can fix that with some CSS. Definitely some room for improvement, but wanted to share a patch that works for my use-case.
Comment #24
linyike CreditAttribution: linyike commentedHi bjmiller121,
Thank you for your code. It functions well, but when I click the Webform tab in my page, following message appear above the form components.
Notice: Undefined index: description_position in theme_webform_element() (line 3582 of D:\Website\sites\all\modules\webform\webform.module).
Notice: Undefined index: description_position in theme_webform_element() (line 3613 of D:\Website\sites\all\modules\webform\webform.module).
So do I need to fix something?
And this only appear every first time I click the Webform tab for a Webform page.
Comment #25
DaveH1234 CreditAttribution: DaveH1234 commented@bjmiller121 #23
This patch works great with my extra additions so that it works with existing forms not just newly create forms.
@linyike #24
This error message only applies to form elements that you haven't updated since you made these custom changes. To fix this you just need to wrap the IF's in an isset() to check if it exists first before the comparison.
How i've fixed it:
function theme_webform_element($variables) line 3578(for latest webform version 7.x-4.9)
and on line 3610(ish)
Hope this helps.
Comment #26
DaveH1234 CreditAttribution: DaveH1234 commentedJust going to open this again to see if we can request this as an actual feature. The code provided by @bjmiller121 #23 (lines in patches are incorrect but manually applying in correct places works fine) and some tweaks by myself #25 provide a good option to allow description fields to be above the input box.
Thanks.
Comment #27
paramnida CreditAttribution: paramnida commentedI have re-rolled the patch based on DaveH1234's changes in #25. This patch is for version 7.x-4.9. Hopefully it works. I'm still kind of new to making patches. :-)
Comment #29
paramnida CreditAttribution: paramnida commentedSubmitting the patch again.
Comment #30
DanChadwick CreditAttribution: DanChadwick commentedTests were failing due to the unrelated issue #2510216: Tests are failing (Testbot, local via UI, drush test-run. Updating version to dev and re-queuing.
If this patch doesn't apply to the latest dev, it will need a re-roll. Please always make patches against the latest dev at the time.
Comment #34
DanChadwick CreditAttribution: DanChadwick commentedNeeds a re-roll for the latest dev.
Comment #35
Rik Gadsby CreditAttribution: Rik Gadsby commentedwould love to know if this happens, have had so many requests for this to be proper webforms option
Comment #36
matthewhilbert CreditAttribution: matthewhilbert as a volunteer commentedpatch re-rolled against HEAD
Comment #37
DanChadwick CreditAttribution: DanChadwick commentedComment #39
DanChadwick CreditAttribution: DanChadwick commentedThanks for the patch. It needs a little love.
I'll tend to this if I get a chance.
Comment #40
DanChadwick CreditAttribution: DanChadwick commentedThis patch:
All-in-all, trickier that expected. I believe that I've tested this well, but additional testing is always welcome. There are a lot of possible combinations.
Committed to 7.x-4.x. D8 port needed.
Comment #42
DanChadwick CreditAttribution: DanChadwick commentedPort to D8 needed.
Comment #44
fenstratCommitted and pushed to 8.x-4.x. Thanks!
Comment #46
Jérôme DehorterHi fenstrat,
I try to find this option in webform 8.x-5.0-rc23 and I don't find it. Can you explain where it is ?
Thx.
Comment #47
DanChadwick CreditAttribution: DanChadwick commentedWebform 8 is an entirely different codebase. The branch referred to above was abandoned. If you don't see the option in version 8, open a new feature request.