Skip to main content
1 of 2
tenken
  • 18.4k
  • 2
  • 39
  • 57

Fields are attached to Entities, not Nodes. So the field is either attached to bundle that is your node (for all nodes, pre-existing or not), or it hasnt been attached to that bundle yet.

You can use field_info_field and look at the element bundles to see if your given field is attached to the given Entity. If it isn't you can use field_create_instance to add the field to your entity.

You can get a list of all entity types and inspect their bundle types with the bundles key returned from entity_get_info by calling $site_entity_list = entity_get_info(NULL).

Entities and fields are cached, so be sure you use something like drush cc all to be sure you're looking at up-to-date values for all these function calls.

tenken
  • 18.4k
  • 2
  • 39
  • 57