Hi, In a contenttype I defined a field boolean (3states)
When viewing the content the field is always shown, altough I only want it to show when the field is checked.
I tought this is standard behaviour but for some reason it shows the label with anything else when not cheked.
When its checked behaviour is as expected and showing the prefix value.



steeph’s picture

I know that problem. If this is on a node page, the only way to solve this (correctly) is to use a custom template for that content type (or node).

But I would think about hiding the field's label altogether and instead integrate it in the field's value. If you set the off value of the field to nothing, the field should be displayed as nothing of it is off.

byenary’s picture

I think I'll solve this then with custom module chekking for the value and then hide it if needed

FinderFees’s picture

Would you mind sharing how you did this? Did you end up building a custom module, or did you find some other way? I have the same need.

thesame-’s picture

Why dont you just create formatter for it?

 * Implements hook_field_formatter_info().
function HOOK_field_formatter_info() {
  return array(
    'boolean' => array(
      'label' => t('Boolean - hide if false'),
      'field types' => array('list_boolean'),

 * Implements hook_field_formatter_view().
function HOOK_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  $settings = $display['settings'];
  if ($display['type'] == 'boolean') {
    $allowed_values = list_allowed_values($field, $instance, $entity_type, $entity);
    foreach ($items as $delta => $item) {
        if (isset($allowed_values[$item['value']])) {
          $output = field_filter_xss($allowed_values[$item['value']]);
        else {
          // If no match was found in allowed values, fall back to the key.
          $output = field_filter_xss($item['value']);
        $element[$delta] = array('#markup' => $output);
  return $element;