Hi all,
I'm trying to add a checkbox field to a custom content type "Trial". The field is to indicate whether people agree with the terms and conditions of the site before hitting submit. So I need it to be a single checkbox which ticks on or off. I also need it to be a required field - the box must be checked before the record is submitted. I've not been able to set a up a field which contains all of these requirements.
I've tried the "Input CheckBox" data type. I just get text. No checkbox appears on the form.
I've tried the "Integer" and "Text" data types with "single on/off checkbox" form element. No checkbox is there.
I've tried the "Integer" and "Text" data types with "checkbox/radio" form element. A checkbox does appear, but when I click save, the form rejects it whether the checkbox is clicked or not.
Ugggh! This is such a small thing and it's stopping me finishing this project. Has anyone used checkboxes like this? Can you please advise?
thanks!
Comments
You might consider using
You might consider using Drupal 7 where the form already is displayed in an overlay.
too late to switch versions
The site is practically finished now...roll out to test on Monday! Is this a problem with Drupal 6 or something? Surely there's a way to do this!
Anyone used checkboxes in Drupal 6?
Ignore my previous answer, it
Ignore my previous answer, it was to another question :)
I just checked – this is
I just checked – this is certainly possible in Drupal 6.20.
If you don't have these options (screenshot) when adding the field, you might be missing Option Widgets module (it comes with CCK and must be enabled).
After adding the field, you need to set 'Allowed values' immediately – two values are needed, with value for 'off' coming first. (there is a help note explaining this)
After you have successfully added the field, check permissions – (depending on what content access setup you use) new fields might be created without any permissions at all.
Why you are not using Legal Module?
Check this great module http://drupal.org/project/legal it comes with checkbox-> agree as a simple click configurable option and it revalidates the user agrement every time the legal text is changed.
----------------------------------------------------------
G.A. Martin, Drupal Developer.
I'm trying to do the same
I'm trying to do the same with Drupal 7:
When users apply to a job offer (i.e. they're adding an application node), they need to accept terms and conditions.
So on the add application node form I need a checkbox (that's ok I managed to do this with a boolean field) and I also need either a link to terms and conditions page or a readonly textblock containing terms and conditions.
Any clue on how to implement this?
Thanks!
Single checkbox, required, but off by default
I also thought it would be quite simple to add a single checkbox on the node add form, that is required, but off by default. In this way a new node would only be saved if the creator explicitly agrees with certain terms mentioned at this single checkbox.
But whatever I try, the checkbox is always on by default, unless it is not required which is not helpfull in this case.
Is there a way to solve this seemingly easy task in an simple manner? It looks that it is not even that easy to achieve with Rules either...
Just make it Not Required
Just make it not required. For an on/off checkbox, 0 (off) and 1 (on) are both valid values, therefore even if the visitor leaves it "unchecked", they have supplied a value. Setting it as "required" tells Drupal that it must be "On", which is doing the opposite of what you want.
It's never too late to have a happy childhood. ;-)
Figured out a way to do it...
For the original poster, if you want to force acceptance of T&C before registration, the legal module or the terms of use module is probably the most appropriate solution.
However, I, like Tino, have a content type that I want a required single checkbox for. The way I finally managed it was to configure the CCK field with the "checkboxes/radio buttons" widget, set the field to be required, but set my "number of values" to unlimited (or anything > 1 works). I still only put one valid option in the "Allowed values list", but setting the "number of values" > 1 makes that one option show up as a checkbox instead of radio buttons. And then they have to select at least one option (the only one!) before the form will validate. Ta-da!
How to change dafault value
I need a single checkbox for accepting the privacy policy. Your approach for CCK field works almost for D7 fields. The only problem I have is that the single checkbox is checked by default. Does somebody know how to make this unchecked by dafault?
Try using a Boolean field
Try using a Boolean field with the single on-off checkbox option.
Brian Gilday
Municode
www.municode.com