Creating entity fields based on the fields from another entity

by Jack_Hu   Last Updated December 28, 2017 18:07 PM

I've been trying to create a data structure that resembles something like:

            +-----------+-----------+-----------+
            | Service 1 | Service 2 | Service x |
            +-----------+-----------+-----------+
            |  Price 1  |  Price 2  |  Price x  |
+-----------+-----------+-----------+-----------+---------------+
| Feature 1 |    Yes    |    Yes    |    Yes    | Description 1 |
+-----------+-----------+-----------+-----------+---------------+
| Feature 2 |    No     |    Yes    |    Yes    | Description 2 |
+-----------+-----------+-----------+-----------+---------------+
| Feature x |    No     |    No     |    Yes    | Description x |
+-----------+-----------+-----------+-----------+---------------+

I've created a content entity Services, which has the following fields:

  1. Service Name
  2. Price
  3. Feature 1
  4. Feature 2
  5. Feature x

This works great, until I realise that I'm not including the descriptions of each feature.

Drawing on my knowledge of database normalisation, I intend to extrapolate the description and feature to its own content entity, Services Info. I think that would probably work just fine, with one small exception, I now need to maintain the list of features in two entities, something I'm loathed to do.

Is there any way I can get Drupal to synchronise the fields across two tables? So that if/when I add more features to the Services entity, it'll appear in the Services Info entity, waiting for me to input a description for it?

Or, if there's a better, more Drupally way to approach this problem, then please feel free to chime in!

Tags : 8 fields entities


Related Questions






How to properly delete fields, programmatically?

Updated March 20, 2017 13:07 PM