Problem/Motivation
Currently, field translatable property is set in table field_config, which means all field instanses for a specific field share the same 'translatable' perporty. This could lead to settings conflict.
For example, the most commonly used field 'body' is attached to several content types. Let's say it's used in both content types page and article. Now I want to make the body in page translatable and in article non-translatable. This simple requirement could not be done in current design, because translatable property applies to all field instances. I must create two different 'body' fields for content type 'page' and 'article', and assign different translatable property to either 'body'.
Steps to reproduce
- Install drupal8 with English and stardard profile;
- Enable Language, content translation, and Interface Translation modules;
- Go to 'admin/config/regional/content-language', check 'Content', and make Article and Basic page translatable;
- Leave Body for Article unchecked and Body for Basic page checked. Click save.
- Now Body for Article is also checked in this page, even it's not checked before save.
Proposed resolution
Move the field translatable property from table field_config to table field_config_instance. In this way, each field instanse will have it's own translatable property, and no conflicts.
This could involve many aspects of field settings, like field's own translation setting, but I seriously think is it really necessary to enable field's own translation setting.
User interface changes
No UI changes
API changes
I suppose no api changes.
Comments
Comment #1
smiletrl CreditAttribution: smiletrl commentedThis could be a big design issue. berdir doesn't think it's possible to do this. Anyway, leave it open.
Comment #2
smiletrl CreditAttribution: smiletrl commentedComment #3
YesCT CreditAttribution: YesCT commentedthanks for opening this issue. It will be nice to at least have written down some explanation of why translatability needs to stay a global field setting on shared fields.
Comment #4
plachI'm not sure I see what concern @Berdir has wrt making fields translatable per-instance: since the Entity Field API supports per-bundle settings, altough it does not supports cross-entity-type field definitions, we should be able to proceed here. I'd start by making
field_is_translatable()
andfield_available_languages()
accept a field instance instead of a field.Probably there might be some tricky case where we have no bundle available, here we may want to check all the defined bundles for the given entity type and consider the field translatable if at least one of its instances is.
Probably the migration code to make a field translatable will need to be adapted, hence we might want to wait for the Field API to be fully converted to the Entity Field API.
Edit: Also
field_entity_field_info()
and theDatabaseStorageController
will need to be adjusted. Actually this is a pretty advanced task :)Comment #5
plachwrong tag
Comment #6
smiletrl CreditAttribution: smiletrl commented@plach, glad to see your points here^
So, now we're trying to make a field become an entity? field will become sort of a plugin entity attached to other entities, e.g, user, node?
If the answer is true, I guess there'll be great improvement for Field CRUD API:)
Anyway, may I know who are getting involved and where this discussion takes place? Thanks.
Comment #7
plachActually the Enity Field API is unifying entity field and properties under a single consistent API. Here are the relevant links:
#1346204: [meta] Drupal 8 Entity API improvements
#1346214: [meta] Unified Entity Field API
See also:
http://2012.badcamp.net/program/sessions/fields-and-entities-good-bad-an...
Comment #9
xjmComment #10
YesCT CreditAttribution: YesCT commented#1854056: Handle shared fields in translation settings might be a duplicate
Comment #11
YesCT CreditAttribution: YesCT commented#1807902: add hint to field collapsed global settings: GLOBAL SETTINGS: Number of values (1), Field translation (disabled) related
Comment #11.0
YesCT CreditAttribution: YesCT commentedMake steps to reproduce in ordered list.
Comment #12
plachThis is being addressed in #2143291: Clarify handling of field translatability.