2

I posted a while back and have now successfully implemented a custom field (this was an extension of the DateRange field type to add control over presentation etc...)

I have a few other use cases where I could do with having a modified daterange field as a sub-field in another custom field type, now I know I could implement in the same way in each new custom field type, however, it would be much simpler if I could just drop in my custom daterange field. If this is not possible, is it best just to make my custom daterange the base type and extend this for each field type I need to create? Or is there another solution (I don't want to use paragraphs as I can't get the degree of customisation I want)

1 Answer 1

0

Basically, the question is how to use a custom field in another field as a property.

In an entity a custom field is added by using BaseFieldDefinition::create(). However a property of a field type is added by DataDefintion::create() or MapDefinition::create() and only basic types are defined (in DataDefintion class) to be used as DataDefintion. So It doesn't look like it is possible to have a custom field in another custom field.

References:

  1. Fieldable field explains the problem of having a field inside a field
  2. Entity API explains how each data type and field type are defined.
  3. Same issue filed in d.o at #2874458

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.