Fix Issue Translated Object in a Gridfield

New Objects created via a Gridfield have the default Locale applies instead of Current, this checks that any new DataObejcts have the correct Locale applied
This commit is contained in:
Richard Rudy 2016-11-19 15:17:02 -05:00 committed by GitHub
parent 06da948586
commit a07363a0d0

View File

@ -1155,6 +1155,11 @@ class Translatable extends DataExtension implements PermissionProvider {
// used in LeftAndMain->init() to set language state when reading/writing record
$fields->push(new HiddenField("Locale", "Locale", $this->owner->Locale));
//ensures New DataObjects in a Gridfield have the correct Locale applied
if($this->owner->ID == 0 && !($this->owner instanceof SiteTree)) {
$this->owner->Locale = self::get_current_locale();
}
// Don't apply these modifications for normal DataObjects - they rely on CMSMain logic
if(!class_exists('SiteTree')) return;
if(!($this->owner instanceof SiteTree)) return;