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.
Hi,
Is there a way which doesn't involve custom theming to make a single checkbox appear inline with it's label? What I have right now is a select element, with the label filled in (since it's mandatory), and single option with a trailing pipe 'newsletter_signup|'. The checkbox appears on a separate line, which is rather ugly. Any suggestions?
Thanks,
--Andrew
Comment | File | Size | Author |
---|---|---|---|
#17 | new-naming-with-notes.png | 14.89 KB | Francewhoa |
#17 | new-naming.png | 20.77 KB | Francewhoa |
#13 | display_to_end_user-03.png | 7.13 KB | Francewhoa |
#12 | single_checkbox_mockup-02.png | 27.38 KB | Francewhoa |
Comments
Comment #1
deviantintegral CreditAttribution: deviantintegral commentedUpdating since this still affects the latest version, and -dev as well. I think the best option would be to implement a 'hidden label' option for fields.
Thoughts?
--Andrew
Comment #2
deviantintegral CreditAttribution: deviantintegral commentedThis still applies to 6.x-2.8, but at this point it really is a feature request.
Comment #3
quicksketchYep, this still isn't possible. I think a single checkbox might warrant a separate component type, since it doesn't need any of the complexities of the select component.
Comment #4
gpk CreditAttribution: gpk commented@deviantintegral: I've worked round this by hiding the container label tag with CSS and then the problem goes away for sighted users at least. Possibly not an ideal approach, though I did wonder if it would be possible to make the label optional in some situations at least, or provide a way of not outputting it.
However if we are talking about more than one checkbox in a checkboxes element I suspect that good markup will always wrap them in a label element (but I'm no HTML guru so am guessing rather). Probably this feature plus #536236: Custom CSS classes for form components would meet all my requirements (am converting another site to Drupal/webform) without having to resort to hacky CSS/HTML.
Comment #5
R.Hendel CreditAttribution: R.Hendel commentedYou have to use a selectbox and configure it so that it allows multiple choices.
When you configure just one single option, users can click and unclick this checkbox.
I think that's what you want?
Not very intuitive but working ;-)
Comment #6
gpk CreditAttribution: gpk commented@5: precisely, something more intuitive is needed!
Comment #7
arski CreditAttribution: arski commentedYes, and apart from that it renders the element as "checkboxes" #type as opposed to the "checkbox" one, meaning that the styling and the processing is different.
Would be really great to have this as a proper, separate checkbox.
Thanks
Comment #8
peterx CreditAttribution: peterx commentedThis is still a problem with version 6.x-3.0-beta2. The horrible workarounds required to make useful checkboxes are impossible for non technical people, making the module unusable for delegating forms creation to content editors. Why should we have to hide the label then provide a value? The value adds the complication of an extra array level in the result, making everything else too complicated.
The very first form I tried to create in Webform requires a list of independent checkboxes on the first page with each subsequent page conditional on those checkboxes. I am documenting the steps so content editors can repeat the steps for their forms. The process is too complicated. I will have to look elsewhere for forms creation.
Comment #9
quicksketchYep, thanks for your input peterx. We're only 100 lines of code away from a single checkbox, but I've got more pressing issues to take care of. Patches to add such functionality would be welcome, though I'm worried about the confusion between a "Single Checkbox" and the current "Select Options". I think we'd frequently end up with people trying to make a set of checkboxes by adding a lot of single checkboxes, not a good situation.
Comment #10
peterx CreditAttribution: peterx commentedI look forward to the update with the checkbox. My requirement is to ask the usual lifestyle questions as independent options. Editors will add and delete options. People can select any mix they want. Each option will make a subsequent page appear or not appear. The editors will not have control of the CSS or anything else. The result will look like a list but the questions are not related. Each is a true single checkbox.
Do you watch movies? [ ]
Can you program an 8008 using binary switches? [ ]
Do you eat pasta? [ ]
Comment #11
Francewhoa+1 for an easy intuitive way of creating a single checkbox. I would be happy to contribute patch testing. New features usually go into dev version.
Comment #12
FrancewhoaAbout adding a new option call 'Single checkbox' on the component's setting page at
node/*/edit/components/*
?Here is how it would work. First the user add a 'select' component. Then on the component's setting page the user select 'Single checkbox' option. What do you think? See below mockup to clarify expected result on the component's setting page.
Comment #13
FrancewhoaBelow is the expected result of what would be display to end user.
Notice that the single checkbox is on the left side. This is usually the web standard. Same as multiple checkboxes.
Notice that there is no lable display above the single checkbox component. Being able to hide the component's label would be a nice to have optional feature. This would be set on the component's setting page. What do you think? In the meantime the component's label can be hidden with CSS.
Comment #14
quicksketchHmm, this option doesn't make sense if you check "Multiple" or "Select list" options also though. I'd be left wondering which one would win.
Comment #15
FrancewhoaGood point. Two more options:
Single checkbox
.What else? Any idea on how to present a single checkbox option?
Comment #16
quicksketchI think making a separate component makes the most sense for this task, though I'd like somehow clarify checkboxes/radio buttons in general. If there is a component named "Single checkbox" people will frequently think that's what they need to use when making checkboxes in general when they really need to use "Select options" and then turn on "Multiple". The whole situation has been confusing for a long time, adding another component with the name "checkbox" is likely to further muddle things for new users.
Comment #17
FrancewhoaMy vote goes for making a separate component.
Good point about the possible confusion. To avoid confusion I suggest a new component's name for the front end. No change to the code but just change
toselect
select multiple checkboxes
. Find below mockup to clarify. What do you think?Comment #18
quicksketchThat's fine except that select.inc handles a lot more than just checkboxes. It handle four separate types of elements:
- Checkboxes
- Radio buttons
- Select list (single selection)
- Select list (multiple selection)
Comment #19
FrancewhoaAbout creating the following new 4 components? Each one with its own
*.inc
file?- Select list (listbox)
- Select list (radio buttons)
- Select list (single checkbox)
- Select list (multiple checkboxes)
If part of the code is shared by more than one than about creating a
select_shared.inc
file?Comment #20
quicksketchThat's an interesting suggestion. I've been thinking about how to have one file provided multiple components for a long time, I've never really considered just making multiple files and having the code shared between them. Due to the way Webform works however, this would make it impossible to convert a set of radio buttons into a select list (or vice-versa). Ultimately I think we're after the same thing here though, which is a set of components that can be selected with the following names:
- Select list (which can be single or multiple)
- Radio buttons
- Checkboxes
- Single Checkbox
It's just a matter of how to implement this from a technical perspective.
Comment #21
FrancewhoaThe components naming in #20 seems pretty clear to me. End user should not be confuse. I like your components naming version better. It's shorter.
As for how to implement this I'll let other coders handle that. I'm not a coder. I can only contribute to front end stuff. And I would be happy to test patches.
Any volunteer for a patch?
Comment #22
gpk CreditAttribution: gpk commentedWhile we are at it can I throw this related issue into the mix: #713100: "Select" webform component is confusing (renders as HTML select, checkboxes or radios element), which was largely attempting to grapple with similar issues.
Comment #23
quicksketchThanks for referencing that issue gpk. I think we can focus this issue on making the checkbox.inc component file and that other issue on separating selects, radios, and checkboxes. It will likely be a blocker for this issue for purely UI reasons.
Comment #24
Alan D. CreditAttribution: Alan D. commentedCross posting - I'm just wondering if #310195: Make field labels optional makes it in, then the same single checkbox functionality can be mimicked very easily by simply hiding the title field. This removes the need for the single checkbox field and thus reduces the overall code complexity.
Comment #25
Ludo.RIs it now possible to create a single checkbox (using version 3.2)?
I cannot figure out how to do that.
I think in 2.x branch, there was a "single on/off checkbox"!?
Comment #26
quicksketchNo, it's still not possible and a single checkbox component has never been in Webform. You're probably thinking of CCK, which does have a single on/off checkbox.
Comment #27
Ludo.RYes you're right!
I'll work with radio buttons.
Thanks for the reply!
Comment #28
quicksketchThis can now be solved by just not showing the title of a set of checkboxes and just creating a single option: #310195: Make field labels optional
Comment #29
deviantintegral CreditAttribution: deviantintegral commented/me jumps up and down.
Glad to hear this is fixed!