In this unit:
- You will learn how to decide whether or not to reused fields and share field configurations between entity types.
You can reuse previously defined field: if you define a custom image field for one content type, and you need to have an image field with the same settings on another content type, you can add the same field to the second content type.
Caution:
Some settings of a reused field are shared across all of its instances, while other settings are unique to each instance.
For example, the label of a text field is unique to each field instance (you can name the field "Book Title" on one Content Type, while calling it "Production Title" on another), while the setting for the number of allowed values (also called 'cardinality of a field') is shared (change it for one instance and all of the other instances of the shared field are modified as well).
Why reuse a field
Reusing fields can save you time as it avoids redefining the same fields over and over again.
Reusing fields can be advantageous as it allows you to reuse specific custom theme code and theme logic used to define how that field should be displayed.
Why NOT to reuse a field
Advanced field-level configuration
If you're unsure of certain advanced configurations you may want to do on a field level in the future, it's better not to reuse fields too much.
Example:
With the use of additional modules it's possible to configure field-level permissions and set up scenarios such as "Only users with the 'Staff' role can use and see the 'Internal comment" field. These permissions will apply across all instances of that field - it won't be possible to turn them on or off on a per-content type basis.
Configuration Deployment
Drupal 10 lets you create full or partial exports of your configuration to import into another site. This mechanism is used by developers who build or update functionality on their local copy of a website, and then want to move those configuration changes to the live site without manually having to redo the configurations.
Sharing a field across different entity types can in some cases lead to configuration deployment complications.