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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

deviantintegral’s picture

Version: 5.x-2.0 » 5.x-2.1.3

Updating 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

deviantintegral’s picture

Version: 5.x-2.1.3 » 6.x-2.x-dev
Category: support » feature

This still applies to 6.x-2.8, but at this point it really is a feature request.

quicksketch’s picture

Version: 6.x-2.x-dev »

Yep, 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.

gpk’s picture

@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.

R.Hendel’s picture

Status: Active » Needs review

You 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 ;-)

gpk’s picture

Status: Needs review » Active

@5: precisely, something more intuitive is needed!

arski’s picture

Yes, 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

peterx’s picture

Version: » 6.x-3.0-beta2

This 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.

quicksketch’s picture

Yep, 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.

peterx’s picture

I 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? [ ]

Francewhoa’s picture

Status: Needs review » Active

+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.

Francewhoa’s picture

Version: 6.x-3.0-beta2 » 6.x-3.x-dev
Status: Active » Needs review
FileSize
27.38 KB

About 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.

Francewhoa’s picture

FileSize
7.13 KB

Below 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.

quicksketch’s picture

Status: Active » Needs review

Hmm, 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.

Francewhoa’s picture

Good point. Two more options:

  • Use a radio button instead. So user decides which one wins.
  • Create a new component Single checkbox.

What else? Any idea on how to present a single checkbox option?

quicksketch’s picture

I 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.

Francewhoa’s picture

FileSize
20.77 KB
14.89 KB

My 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 select to select multiple checkboxes. Find below mockup to clarify. What do you think?

quicksketch’s picture

That'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)

Francewhoa’s picture

About 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?

quicksketch’s picture

That'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.

Francewhoa’s picture

The 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?

gpk’s picture

While 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.

quicksketch’s picture

Thanks 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.

Alan D.’s picture

Cross 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.

Ludo.R’s picture

Version: 6.x-3.x-dev » 6.x-3.2

Is 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"!?

quicksketch’s picture

No, 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.

Ludo.R’s picture

Yes you're right!

I'll work with radio buttons.

Thanks for the reply!

quicksketch’s picture

Status: Needs review » Fixed

This 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

deviantintegral’s picture

/me jumps up and down.

Glad to hear this is fixed!

Status: Fixed » Closed (fixed)

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