I need to have a list of all available view modes for an entity type so I can use it as the #options in a select field.

Any ideas? Thanks


I think you are talking about view modes for entities.

$entity_info = entity_get_info('node');
debug(array_keys($entity_info['view modes']));

It would result as

array (
  0 => 'full',
  1 => 'teaser',
  2 => 'rss',
  3 => 'search_index',
  4 => 'search_result',
| improve this answer | |

You may also want to use this function...

field_view_mode_settings($entity_type, $bundle);


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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