A new API is available to specify whether changes to untranslatable fields should affect only the default revision translation. Previously a change to an untranslatable field would always mark all revision translations as affected. Now it is possible to specify that only the default revision translation should be marked as affected via entity bundle info:
/**
* Implements hook_entity_bundle_info_alter().
*/
function my_module_entity_bundle_info_alter(&$bundles) {
$bundles['node']['article']['untranslatable_fields.default_translation_affected'] = TRUE;
}
This information can be retrieved for individual entities via the TranslatableRevisionableInterface::isDefaultTranslationAffectedOnly()
method.
Depending on the value above, EntityUntranslatableFieldsConstraintValidator
will allow only changes to untranslatable fields in the default revision (when all translations are affected), or to the default revision translation (when only the default translation is affected). This allows to enforce the constraint that only a single revision translation is affected in pending revisions.
If your entity has certain fields that weren't previously marked translatable i.e. changed
, etc. that always get modified during a translation revision save, then the validation error can be throw. Simply mark these fields as translatable and the validation error will go away.
If this new validation logic is conflicting with your code, you can disable it by implementing hook_entity_type_alter()
:
function mymodule_entity_type_alter(array &$entity_types) {
$constraints = $entity_types['my_entity_id']->getConstraints();
unset($constraints['EntityUntranslatableFields']);
$entity_types['my_entity_id']->setConstraints($constraints);
}
As an alternative you can hide untranslatable field widgets on translation forms.