Error message

The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.

Return Drupal CCK Integer Field Allowed Values List as Array


Drupal 6 (D7 below)

Below is a helpful function that will return the allowed values list for a Drupal CCK Integer Field as an Array.

For example, here is my allowed values list for my cck integer field "field_dg_hole_tee":



function tf_cck_integer_field_allowed_values_list_as_array ($field_name) {
	$sql = " SELECT global_settings FROM content_node_field WHERE field_name = '%s' AND type = 'number_integer' ";
	$global_settings = unserialize(db_result(db_query($sql,$field_name)));
	$allowed_values = $global_settings['allowed_values'];
	$allowed_values_explode = explode("\n",$allowed_values);
	$allowed_values = array();
	foreach ($allowed_values_explode as $allowed_value) {
		$allowed_value_explode = explode("|",$allowed_value);
		$allowed_values[$allowed_value_explode[0]] = trim($allowed_value_explode[1]);
	return $allowed_values;


$field_name = "field_dg_hole_tee";
$tees = tf_cck_integer_field_allowed_values_list_as_array($field_name);


Drupal 7

Thanks to Laurens from Rotterdam in The Netherlands for this Drupal 7 snippet!


function get_list_integer_allowed_values_as_object() {
   $data               = array();
   $result             = db_query("SELECT field_name , data FROM {field_config} WHERE type='list_integer'");
   foreach ($result as $record) {
     $tempvar  = unserialize($record->data);
     $data[$record->field_name] = $tempvar['settings']['allowed_values'];
 return $data;

It will return something like this:

array(15) {


 array(7) {


   string(9) "Penthouse"


   string(9) "Apartment"


   string(6) "Studio"



 array(4) {


   string(3) "Yes"


   string(2) "No"



Add new comment