field_view_value returns null for boolean field I have a custom field field_sold which contains a single boolean value. I'm trying to use the following function to retrieve the content of the field, but it always seems to return null:

function &lt;theme&gt;_render_field($node, $field_name, $delta = 0, $display = array()) {
   $field = field_get_items('node', $node, $field_name);
   $field = field_view_value('node', $node, $field_name, $field[$delta], $display);
   return render($field);  
}


When trying to dumping the $field variable between the calls to field_get_items() and field_view_value() I recieve the following output:

// after field_get_items()
Array ( [0] =&gt; 
   Array ( [value] =&gt; 1 ) ) 
// after field_view_value()
Array ( [#markup] =&gt; [#access] =&gt; 1 ) 


When I'm using the above function for other fields it works as expected, for instance when rendering a image field like this:

print &lt;theme&gt;_render_field($node, 'field_image', 0, 
                     array('type' =&gt; 'image', 
                           'settings' =&gt; array(
                           'image_style' =&gt; 'object_200x300',
                           'image_link' =&gt; 'content')
                           ));
Set 

$display['type'] = 'list_key';


in your theme function to get not null key of field. Or create own formatter, for ex.

function mymodule_field_formatter_info() {
  return array(
      'my_formatter' =&gt; array(
          'label' =&gt; t('My formatter'),
          'field types' =&gt; array('list_boolean'),
      ),
  );
}


function mymodule_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  $settings = $display['settings'];

  switch ($display['type']) {
    case 'my_formatter':
      foreach($items as $delta =&gt; $item) {
        $value = $item['value'] == 1 ? '&lt;span class=""&gt;ON TEXT&lt;/span&gt;' : '&lt;span class=""&gt;OFF TEXT&lt;/span&gt;';
        $element[$delta] = array(
            '#markup' =&gt; $value,
        );
      }
      break;
  }

  return $element;
}


and after that set 

$display['type'] = 'my_formatter';


in Your theme function