I want to emphasise that I don't want to use field_collection.

I want to create custom field type that can be reused in different entities and bundles. This should be kept in one custom module. So when I enable it and go to 'manage fields' page on any entity type then I should be able to pick up my custom field type (e.g.: foo). This field should be combined with base image field and simple one line text field. I don't want to use field_collection module because as far as I see I can not recreate my field, even features give me ability to export it in field_base section. After flushing my drupal to clean instance and enabling this feature again I can not see it in 'Add existing field' in [structure > content types > CONTENT_TYPE > manage fields] page. Maybe I'm doing something wrong. (?)

So how can I programmatically create custom field type with existing base fields? e.g. Custom foo field type with image field and text field?

OR (if I done something wrong with features..)

How can I export custom field collection with sub fields, only as a field definition (not attached to any content type/entity) using features?


1 Answer 1


What you want to do is create a field type with multiple properties. This is indeed more efficient than a field collection, because a property only needs one more column in the field table, while a field collection is a complete new entity in the database.

This is the documentation how to build a custom field type from scratch in a custom module:


As you want to add a property to an existing field type use this tutorial


and extend the class ImageItem for the new field type. You also need to extend ImageFormatter to display and ImageWidget to provide a form field for the new property.

  • Just noticed this is D7, but this is the same method
    – 4uk4
    Feb 1, 2017 at 12:46
  • Thanks, but I forget to tag it that this question is about D7. But anyway I will try to search by my self.
    – sobi3ch
    Feb 1, 2017 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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