I'm having some issues with boolean field. I want to have few fields that can be turned on/off, which will be used to show if something is available in the content.

So I thought single on/off checkbox is the way to go. Well, apparently not because even if I don't select the checkboxes, they're still rendered in the code. And I need them to NOT render.

Checkboxes/radio buttons works in this way, but it creates 3 selectable options (on, off, not available) whether I would like to have only one checkbox.

I also tried using List (text) for my needs, but here I'm limited by the fact I can't add individual CSS id/classes to every item in the list.

My target is using these lists/checkboxes, hidding them in CSS and replacing with icons. I did something like this few months ago but now I can't remember how exactly I achieved what I needed.

2 Answers 2


Turns out field of the List (text) type was enough, just needed to create my own field template for that field. With this I was able to render additional classes/id and change the way the field is build, making it possible to style as needed using CSS.


You can hide them either through CSS or you can unset them using the form_alter if you are using forms. Look at the code below In this code, I am unsetting the author on the comment form.

function Mymodulename_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
    if($form_id == 'comment_form) {

If you've added the field to some node then you can unset them using this code.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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