From 405fa7e3cf6c76b82b589ed58114ef3eaac6f9c8 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 16 Aug 2012 14:22:28 +1200 Subject: [PATCH] FIXED: Allowed hidden "Locale" field to exist in the CMS form for SiteConfig (and other data objects) --- code/model/Translatable.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/code/model/Translatable.php b/code/model/Translatable.php index 0ff6840..5e24328 100755 --- a/code/model/Translatable.php +++ b/code/model/Translatable.php @@ -957,14 +957,14 @@ class Translatable extends DataExtension implements PermissionProvider { } protected function addTranslatableFields(&$fields) { - if(!class_exists('SiteTree')) return; + // used in LeftAndMain->init() to set language state when reading/writing record + $fields->push(new HiddenField("Locale", "Locale", $this->owner->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; - // used in CMSMain->init() to set language state when reading/writing record - $fields->push(new HiddenField("Locale", "Locale", $this->owner->Locale) ); - - // Don't allow translation of virtual pages because of data inconsistencies (see #5000) + // Don't allow translation of virtual pages because of data inconsistencies (see #5000) if(class_exists('VirtualPage')){ $excludedPageTypes = array('VirtualPage'); foreach($excludedPageTypes as $excludedPageType) { @@ -1149,8 +1149,7 @@ class Translatable extends DataExtension implements PermissionProvider { * This function DOES populate the ID field with the newly created object ID * @see SiteConfig */ - protected function populateSiteConfig() - { + protected function populateSiteConfig() { // This is required to prevent infinite loop during createTranslation // If createTranslation is called directly on SiteConfig then this function could // be called twice, but it will not cause harm for this to happen. @@ -1192,8 +1191,7 @@ class Translatable extends DataExtension implements PermissionProvider { /** * Hooks into the DataObject::populateDefaults() method */ - public function populateDefaults() - { + public function populateDefaults() { if (empty($this->owner->ID) && $this->owner instanceof SiteConfig) $this->populateSiteConfig(); }