Field instance drupal hosting
When we go to the path /admin/structure/types/manage/article/fields and use Add new field option or Add existing field option, does that create a field or create field instance or attach field instance? How to differentiate between them? So programmatically when to use field_create_field. field_create_instance and field_attach api?
In the field api documentation it only tells admin UI and never talks about the path where to create both fields and field instance. So its confusing. I dont even know if I even make sense.
asked Jan 21 '13 at 15:59
it is always better to use the same field instance if the purpose is or the function is going to be same. for example you have different content type with the same taxonomy vocab to be added in all. it would be better to add the same field to all the content type rather than create different fields to each content type. Internally this would decrease the number of tables build by drupal. and searching on the vocab would become better. - Mohammed Shameem Jan 21 '13 at 16:57
So fields that we see at path node/add/article are field instances (which are reused at several different entity types). And fields at path /admin/structure/types/manage/article/fields are fields. In database I don't see a field instance table but only field_data table which, I guess, we get when we first create a field at path /admin/structure/types/manage/article/fields using field_create_field. And an instance is then attached to a bundle (article in this case) that we see at path node/add/article. - Eugene Gerome Jan 21 '13 at 17:20
A field is the basic definition of a field itself. A field instance is an instance of that field, attached to an entity/bundle.
To check if the field, or instance exists, use
When you create a field through the UI, Drupal always creates a field instance on that entity/bundle.
If you're adding an existing field, the field data is cloned and a field instance is created on the new entity/bundle.
Lastly, field settings apply globally to that field, field instance settings can vary between entity bundles.