In my module, I define a custom content type, and custom fields by using
hook_field_info(), and so on. I'd like to programmatically add field instances of my field to the created content type when my module is enabled/installed.
I know there is the possibility of creating the content type, and the field in the database by using
field_create_instance(), but this is not what I want, since during the development the field definitions will change, and in the latter scenario I would have to uninstall and reinstall the module every time I change a field/content type.
I tried using
field_create_instance() in my module's
hook_enable(), but Drupal says that the field I try to add does not exist or is inactive.
Is there an elegant way to let the module define fields, and attach them to content types when enabled (and of course detach them on uninstall or disabling it)?