mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
FIXED: Allowed hidden "Locale" field to exist in the CMS form for SiteConfig (and other data objects)
This commit is contained in:
parent
9978765abc
commit
405fa7e3cf
@ -957,14 +957,14 @@ class Translatable extends DataExtension implements PermissionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function addTranslatableFields(&$fields) {
|
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
|
// Don't apply these modifications for normal DataObjects - they rely on CMSMain logic
|
||||||
|
if(!class_exists('SiteTree')) return;
|
||||||
if(!($this->owner instanceof SiteTree)) return;
|
if(!($this->owner instanceof SiteTree)) return;
|
||||||
|
|
||||||
// used in CMSMain->init() to set language state when reading/writing record
|
// Don't allow translation of virtual pages because of data inconsistencies (see #5000)
|
||||||
$fields->push(new HiddenField("Locale", "Locale", $this->owner->Locale) );
|
|
||||||
|
|
||||||
// Don't allow translation of virtual pages because of data inconsistencies (see #5000)
|
|
||||||
if(class_exists('VirtualPage')){
|
if(class_exists('VirtualPage')){
|
||||||
$excludedPageTypes = array('VirtualPage');
|
$excludedPageTypes = array('VirtualPage');
|
||||||
foreach($excludedPageTypes as $excludedPageType) {
|
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
|
* This function DOES populate the ID field with the newly created object ID
|
||||||
* @see SiteConfig
|
* @see SiteConfig
|
||||||
*/
|
*/
|
||||||
protected function populateSiteConfig()
|
protected function populateSiteConfig() {
|
||||||
{
|
|
||||||
// This is required to prevent infinite loop during createTranslation
|
// This is required to prevent infinite loop during createTranslation
|
||||||
// If createTranslation is called directly on SiteConfig then this function could
|
// If createTranslation is called directly on SiteConfig then this function could
|
||||||
// be called twice, but it will not cause harm for this to happen.
|
// 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
|
* Hooks into the DataObject::populateDefaults() method
|
||||||
*/
|
*/
|
||||||
public function populateDefaults()
|
public function populateDefaults() {
|
||||||
{
|
|
||||||
if (empty($this->owner->ID) && $this->owner instanceof SiteConfig)
|
if (empty($this->owner->ID) && $this->owner instanceof SiteConfig)
|
||||||
$this->populateSiteConfig();
|
$this->populateSiteConfig();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user