Problem/Motivation
Field translatability is defined at two levels:
- At field storage definition level it's defined whether the field supports translation and thus should have a storage supporting multilingual values.
- At field definition level it's defined whether the field is enabled for translation and thus actually be assigned multilingual values.
Currently the Field UI creates fields with untranslatable storage, which makes the Content Translation module simply ignore them, so they will never be translated as no UI to enable translation is exposed.
Proposed resolution
Make the Field UI create fields with multilingual storage by default, which is the same default we have in FieldStorageConfig, this way it will be possible to enable or disable translation later. Additionally clean-up the places that were not properly updated when introducing the split between field storage definition and field definition in the first place.
Remaining tasks
- Commit
User interface changes
None
API changes
None
Beta phase evaluation
| Issue category | Bug because field translation is broken for all fields created through the UI. |
|---|---|
| Issue priority | Critical because this severely reduces the content translation functionality for any entity type relying on the Field UI. |
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | field-ui_untranslatable-2401497-28.patch | 14.42 KB | plach |
| #9 | field-ui_untranslatable-2401497-9-test-fail.patch | 2.47 KB | plach |
Comments
Comment #1
plachActually critical :)
Comment #2
plachLet's try this as a start.
Comment #3
plachComment #5
plachThis should be better.
Test coverage additions in the next patch.
Comment #6
plachComment #8
plachThis should fix the last failures, no additional test coverage yet.
Now I recall why
FieldConfigis currently defaulting to TRUE: that's to be consistent with base fields, which unless overridden share the same value for field storage and field translatability. With the current patch, this is the scenario we get with JS disabled on the Content Translation settings page, before the form is submitted for the first time:However after saving the form, base field definitions are overriden with untranslatable values for all untranslatable bundles.
Not sure whether we want to retain this inconsistency or the one I was trying to fix by changing
FieldConfig's default (Field API vs Field UI). Since fixing the latter involves an API change probably we should keep the current behavior after all. The clean-up implemented here should be ok anyway.Comment #9
plachAdded test coverage.
Comment #10
plachSlightly improved test coverage.
Comment #12
plachComment #13
plachComment #14
andypostWhy not make this configurable when field is created?
Comment #15
gábor hojtsy@plach: I believe the UI problem shown in #8 is preexisting and is not in scope here neither is due to this patch right? So I don't think we should be concerned with that.
Comment #16
gábor hojtsyFix tags.
Comment #17
andypostThe related issue changes the forms
Comment #18
berdirWhy the prio change?
This completely breaks the ability to have translated fields, without a workaround other than manually editing config files. Sounds critical to me.
Comment #19
plach@andy:
Well, configurable fields always support multilingual storage, so I don't think it's worth providing an additional concept for users to understand, when in most cases if they don't want a field to be translated they just need to leave translation disabled. The main idea behind making the value alterable, is that modules like Commerce relying on configurable fields for their business logic (not sure that's still the case, btw) can make sure that the Price field, for instance, is never enabled for translation.
@Gabor:
Nope, the inconsistency shown in #8 is introduced by the patch. This is HEAD after performing a clean installation and disabling JS:
To sum up: I think the patch is ready to go, but I changed my mind about the default status of
FieldConfig::$translatable. Reverting that change should just imply of a few changes in some assertions and default config files, as most of the changes performed to tests should be good anyway.Comment #20
gábor hojtsy@plach: ok I meant that the entity is not enabled for translation while the fields are; what would be a bad side effect of making them still default to TRUE for their configuration? sounds like that would still be ignored unless the entity bundle is also configured to be translatable?
Comment #21
plachYep, in fact I think that the HEAD inconsistency where the UI creates untranslatable Field definitions as opposed to the API that creates translatable Field definitions, is way less problematic than having base fields and configurable fields behaving differently when handled via the API.
Btw, I just realized that
ContentEntityBase::addTranslation()lets you create an entity translation programmatically even if the bundle is not enabled for translation, which is not a Good Thing.If there are no objections I'd roll a new version of the patch reverting the change to the
FieldConfig::$translatabledefault.Comment #22
gábor hojtsyThat sounds like less of a change compared to how it works currently, so fine with me :)
Comment #23
plachHere it is
Comment #24
plachUpdated summary
Comment #25
andypostThere's a separate issue for default values for fields. So as bug this RTBC
I just wonders why form hardcodes default values when their defaults should be taken from field entities.
Looks good to me.
Comment #26
gábor hojtsySo this is the key change in the patch. I looked into what @andypost asked and there does not seem to be a field storage config instance yet to take default values from. We could create one to init this value but then would throw that away later. That may be better to keep consistency.
Given that the defaults are now both true for storage and field config, neither the removed, neither the added translatable booleans are needed changes, right? At least the added ones don't need to be added, since it still defaults to TRUE? Not having those extra things in the patch would make it much simpler to review.
Comment #27
berdir1. Yes, the thing is that at this point, we do not yet know if we will create a new storage or re-use an existing one. However, it is possible that the refactoring that @amateescu is working on in #552604: Adding new fields leads to a confusing "Field settings" form will change that.
Comment #28
plachI agree with #25, however fixing that feels fairly out of scope here.
About #26.2: I reverted some changes, but I added some more to make sure people can use tests as an example of how code should be written. AAMOF there's no need to set anything to translatable, as the default is TRUE everywhere. I'd like to keep this clean-up because the current test code was not cleaned-up when we split translatability between Field and Field storage, and it's currently quite confusing.
Comment #29
plachComment #30
plachComment #31
gábor hojtsyALl changes look good to me and my concerns are addressed. The test cleanups are good. No need to set things to something they are already set to :D
Looks all good to get in.
Comment #32
alexpottCommitted 942df46 and pushed to 8.0.x. Thanks!
Thanks for completing the beta evaluation.
Comment #34
gábor hojtsyYay, thanks!
Comment #35
yched commented@plach++