I am creating a new issue specifically about the single on/off checkbox widget field to highlight the current lack of support for this specific form component. I, and others it seems (see #759634, #360824), have spend a lot of time trying to figure out why single on/off checkboxes don't work with Conditional Fields, and hopefully this will save others some time, and may encourage someone looking for a solution.

The single on/off checkbox is an ideal way to capture boolean values - which is a much better UI component than two choices in a select box, and far more preferable to radio boxes - because a third "N/A" radio box is required for not-specified-yet (or default), and three lines (or columns) are required to display the options.

peterpoe, you say 'The reason is that the "off" value of a single checkbox is never sent to the form', and I appreciate we don't want to introduce any security leaks. An idea comes to mind which you have probably thought about and dismissed as unworkable, but just on the very slim off-chance you haven't considered it, I'll air it... Is there a way something like isset() can be used in the module for detecting whether a single on/off checkbox has been selected? Wouldn't isset(
) be false if the check box hasn't been selected, and true if it has? Your knowledge if PHP and Drupal is far greater than mine, and you can probably dismiss this pitiful idea very quickly. I have never created a patch and regrettably don't have time to explore this further at the moment...

Thanks for a very useful little module.

Comments

PepeMty’s picture

Subscribing.

I have a similar request, for select select list though.
I have 4 CCK fields (3 select lists and one text line). Ideally I need to hide the other 3 fields (or their options) if one, and only one option of any other field is selected --or written in it.

Warm regards from sunny México!
:-)
José

phayes’s picture

subscribing

Swipular’s picture

+1 subscribing

mordek’s picture

+1 subscribing

leenwebb’s picture

I'd also love to see required-checkboxes supported as controlled fields.

AtomicTangerine’s picture

Priority: Critical » Normal

sub!!! (not for the AND/OR support PepeMty mentioned, nor leenwebb's of the required property being overridden as those are separate issues in other issue threads), but for single on/off checkbox support.
I tried the "has value" condition, where it gave me the checkbox to check, storing that as a value of '1'. Since the box is made with both 'on' and 'off' values, why wouldn't this work?

also downgrading priority because I feel that it's not really that bad to switch to yes/no checkboxes, that yes, include that pesky "none", but I think (untested) that a condition could be put on that "none" value, that would make a (custom?) error message appear, if there's some reason you don't want the field to be required.

Also, before submitting this, I did some quick research for those 2 talking about other issues.
The AND/OR support request seems to be here: http://drupal.org/node/719068
And the overridden required property issue is here for d6: http://drupal.org/node/453204, and for d7 is here: http://drupal.org/node/1212752

EDIT: ignore me completely.... major brain-dumb moment... thought that was june 28, 2011....sorry....
unsub.... because that functionality exists at least in d7, with the "Value" condition

landing’s picture

I was able to get it to work by setting the widget type to checkboxes/radio buttons instead of on/off.

For your "on/off" controlling field:
- Provide only one value in the allowable values.
- Set the amount in the "number of values" dropdown to anything greater than 1 (so the user sees a checkbox and not a radio button)

For your conditional field
- Set the field to show when the value from your "on/off" field is selected

Boom! All taken care of.

ressa’s picture

That does work, thanks landing!

Widget type: check boxes/radio buttons
Number of values: 2
on|Yes

Leo Pitt’s picture

A couple of problems with the solution in #7 ..

First, the resulting field has a label...

This is the form label:
[ ] Yes

Instead of ...

[ ] This is the form label

Secondly, it seems a bit hacky ... We're setting the "allowed values" field to 2 in order to make the field behave in a single on/off-like way, but we don't really want 2 allowed values ....

kenorb’s picture

Status: Active » Closed (won't fix)

No patch, so sounds like won't fix, unless the same is happening in Drupal 7.