Say I have the machine name of a given field collection. How can I programmatically get the names of the node bundles where one would find this field collection? This would be the same information you see on the admin/structure/field-collections page.


What about:

$bundle = db_query("SELECT bundle, entity_type FROM field_config_instance WHERE field_name = :field_name", array(':field_name' -> $field_name))->fetchAll();

If you know the enity_type then you can use field_info_instances().

  • The query doesn't show me the relationship between bundles and field collections, but I can dig that info out of the giant array returned by field_info_instances(). Thanks! – user1359 Apr 29 '15 at 14:41

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.