Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have a field in Drupal called resource_type, and I wanted to get all allowed values. Is there any easy way to do this with a command, or do I have to do a database query? I'm not seeing anything specifically that would make this easy.

share|improve this question
up vote 5 down vote accepted

For list type field you can use list_allowed_values function , You can also use field_info_field($field_name) for more details about field.

$my_field = field_info_field('field_resource_type');
$allowed_values= list_allowed_values($my_field);
share|improve this answer
Hrm, when I am using list_allowed_values, it keeps giving me a "cannot use string offset as array" error. My syntax is as follows: $list_allowed = list_allowed_values("field_resource_type"); – Andrew Alexander Feb 25 '14 at 16:18
Can you try Updated solution ? – Anil Sagar Feb 25 '14 at 16:20
Yes, that works, thank you. – Andrew Alexander Feb 25 '14 at 16:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.