1

I'm currently creating a form where the user is supposed to check a (sometimes large) number of checkboxes. The problem is that I only want the checkboxes visible, not their label (or key) while the user is filling out the form. Is this possible?

Currently it looks like this:

[ ] label [ ] label [ ] label etc.

I'm aiming for:

[ ] [ ] [ ] ... [ ]

I'm using Drupal 6.22 with CCK 6.x-2.9. Other related modules in my form that will interact with the checkboxes are Conditional Fields 6.x-2.0 and Multicolumn checkboxes/radios 6.x-1.6

Any help is appreciated. Thanks in advance.

2

you can use visibility:hidden; (and height and/or width 0px). I use visibility:hidden; when display:none is not useful (issues of inheritances of CSS, or maybe still you can need the values of the hidden elements).

Other suggestion. I have several forms that use lots of checkboxes, so I use Vertical Tabs http://drupal.org/project/vertical_tabs to divide the forms in several tabs, to show only one group of checkboxes per tab. So here is not necessary to remove labels of checkboxes.

| improve this answer | |
1

Probably the wrong way to do it, but I found the labels go away if you uncheck the Use field label instead of the "On value" as label in the Content Types->Fields dialog.

| improve this answer | |
0

If you just need to hide the label you could probably target it with CSS and display:none;. It's probably one of these classes: .field-label .field-label-inline .field-label-inline-first. You can check out the template files in the cck themes folder if you want to modify the behavior.

Template: [modules folder]/cck/theme/content-field.tpl.php

Another helpful resource is hook_form_alter but with CCK you will want to review the #after_build option. This page discusses how to alter cck elements. http://drupal.org/node/726282

| improve this answer | |
  • I read drupal.org/node/726282. Could you please tell me how can I achieve the 3rd point that mentioned in that page. 3. If you're trying to do anything with radios, checkboxes, or similar, you'll also notice that required properties such as #options do not exist yet, in either place. Those come later. – ARUN May 19 '14 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.