How can I get all options for a cck field?

For example, There is a field with 3 options in allowed values, like option1, option2, option3.Is there any function which receive the field name and returns option1 to option3?

up vote 6 down vote accepted

In Drupal 7 you can use field_info_field(), while in Drupal 6 you can use content_field_instance_read(), which is defined in the CCK module.

As @Lauri said:

You can also use list_allowed_values().

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

You can also use list_allowed_values().

$field = field_info_field('field_name');
$allowed_values = list_allowed_values($field);
  • This should be marked as correct answer. – rugar Apr 11 '17 at 19:44

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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