Ever wanted to retrieve a list of allowed values of select list, here's a sample code:

= field_info_field('FIELD_NAME');
$allowed_values = list_allowed_values($field);

The field_info_field function returns data about an individual field.

The list_allowed_values function returns an array of allowed values for a list field.

But the above code will only work for select list, not for node reference or other types of references. _field_allowed_values() function is a custom function which returns allowed values of reference type field. The function returns allowed values for node reference and term reference field and can be extended to get allowed values of other reference fields as well.

function _field_allowed_values($field_name) {
// retrieve field configurations from DB.
$allowed_values = array();
$query = db_select('field_config');
fields('field_config',array('type', 'data'));


$result = $query->execute()->fetchAssoc();


// Allowed references type
$ref_type = array(


$field_config = unserialize($result['data']);
      if (
in_array($result['type'], $ref_type)) {
        if (
$result['type'] == 'node_reference') {
$node_types = array_filter($field_config['settings']['referenceable_types']);


$query = db_select('node');
$query->condition('type', $node_types, 'in')
condition('status', 1)
fields('node', array('nid', 'title'));
$allowed_values = $query->execute()->fetchAllKeyed(0, 1);
        elseif (
$result['type'] == 'taxonomy_term_reference') {
$allowed_values = taxonomy_allowed_values($field_config);
      else {
$allowed_values_raw = unserialize($result['data']);
$allowed_values = (!empty($allowed_values_raw['settings']['allowed_values']) ? $allowed_values_raw['settings']['allowed_values'] : array());




$field = _field_allowed_values('FIELD_NAME');