automatic class to all boolean fields I have a Boolean field on a content type. Possible values are completed and not completed. The default rendering is not satisfactory though since it doesn't include any CSS class to represent the boolean state (true, false) so I cannot act on this using CSS or JavaScript.

&lt;div class="field 
            field-name-field-status
            field-type-list-boolean
            field-label-inline
            clearfix"&gt;
  &lt;div class="field-label"&gt;Completion status:&amp;nbsp;&lt;/div&gt;
  &lt;div class="field-items"&gt;
    &lt;div class="field-item even"&gt;completed&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


What's the best way to add such a class on .field or .field-item?

What I've tried so far:


hook_field_display_alter but this doesn't provide me with data nor field type
hook_node_view but I cannot iterate fields by type. I'd need to pinpoint the specific field instance I need to modify but I don't know that in advance.
by providing a custom node template, but this solution is not generic for all occurrences of a boolean field
You can implement hook_preprocess_field() and add the class there.

Get field type :

$element = $variables['element'];
$type = $element['#field_type'];


Add something to field class :

$variables['classes_array'][] = 'class-name';