I want to have 2 tabels in DB, like: "orders" and "orders_files". Where "orders" has many "orders_files".

How to do it?

I made content entity called "orders".
Tried having there field "entity_referenece", because I found somewhere on stackoverflow that you can have there multiple id's put.
But that didn't work. Also I haven't found any information about "multiple entity_reference" in drupal 8.

Tried to make two content entieties. I can save, but I can't connect it(probably) nor I can see them in the Views (tried getViewsData()).

How to do it without GUI (programmaticaly)?
Where do I find proper docs about it?
Where can I find dictionary "Drupal to Rest of the programming world"?
Where can I find good documentation about Drupal 8 or comprehensive examples? Cause I'm pissed on this shit.

Comments

Jaypan’s picture

You should use an entity reference field for you. It will handle all the database details for you. You will create the field in the baseFieldDefinitions() of your content entity definition. You can set the cardinality (multiple) there. You'll need to probably look at some implementations in core to see exactly how to do it. Look at all overrides of baseFieldDefinition (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21B...) to find an example that fits what you need.

As for Drupal 8 documentation, there just isn't a lot yet for specific things. Generally you have to look at code in core to figure out how to do stuff. Drupal 7 is much better for finding information.