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

I want to access the values of my field inside hook_block_view().

I tried with field_get_items(), and field_view_field() with no luck.

By the way the block is showing in a page. Is there a way to get the values set in the content type field settings?


share|improve this question
May you show the code you are using? If you want to get the value of a field, field_get_items() is the right function. Which arguments did you pass to the function? – kiamlaluno Dec 26 '12 at 7:32
up vote 1 down vote accepted

You seem to need information about the field itself and not about its instances (neither globally nor in the context of a given entity).

Hence, you would want to do a:

$field = field_info_field('field_my_field');
$keys = array_keys($field['settings']['allowed_values']);
// $keys will now have the set of unique keys for your options as set from
// the field settings page. Eg. Alsace, Aquitaine etc.

field_my_field is the unique name of your field that you have also attached to a content type. To find this out, ensure the Field UI module is enabled, go to the Manage fields page for your content type and look up the Name column for the field in question.

If you are interested in knowing how the values you had set from the settings form go here, check out list_field_settings_form(). Here is a link to the documentation of field_info_field() as well.

share|improve this answer

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.