Hello everybody,
i need to create a custom field type with some fields like title, display and description (as File type), but with two file reference inside.
I have to manage all togherher a pdf attachment and a cover image, all in the same field type. So
- Title
- Description
- Display
- PDF file
- Cover image

i was thinking to ectend FileItem or ImageItem (that both extend EntityReferenceItem), but both have only one reference (the target_id key).
To implement the second reference i should override all of the method of the Item and add the second field in all the references.
There is any other way to do it, maybe with less code (and so less error probability)?

Thanks

Comments

BartK’s picture

I may be misunderstanding you, but it sounds like you want to have a custom field type that includes a lot of fields inside it. If that's the case, you can use the Paragraphs module to assemble your custom field without having to write any extra code at all.

g.rocchini’s picture

Hello BartK! No, you have totally understand the problem :)
I know (and yet used) both Paragraphs and Field Collection, and of course this two modules is the better solution for my problem!
The matter is that the customer want a single field. In many online tutorial (as this one of lullabot https://www.lullabot.com/articles/extending-a-field-type-in-drupal-8) i have find how to extend a single field, but all the guides help to add simple field like string, interger and so on.
The question was about extend with another attachment.
Thanks