mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
Merge pull request #231 from micmania1/cms-dependency
This commit is contained in:
commit
1ad0d0b0a2
@ -168,7 +168,7 @@ class TranslatableCMSMainExtension extends Extension {
|
|||||||
singleton('SiteTree')
|
singleton('SiteTree')
|
||||||
);
|
);
|
||||||
$field->setValue(Translatable::get_current_locale());
|
$field->setValue(Translatable::get_current_locale());
|
||||||
} else {
|
} else {
|
||||||
// user doesn't have permission to switch langs
|
// user doesn't have permission to switch langs
|
||||||
// so just show a string displaying current language
|
// so just show a string displaying current language
|
||||||
$field = new LiteralField(
|
$field = new LiteralField(
|
||||||
@ -215,4 +215,18 @@ class TranslatableCMSMainExtension extends Extension {
|
|||||||
return SiteTree::has_extension('Translatable');
|
return SiteTree::has_extension('Translatable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Injects the locale into a new page on creation.
|
||||||
|
*
|
||||||
|
* @param SiteTree $record
|
||||||
|
* @param Form $form
|
||||||
|
*/
|
||||||
|
public function updateDoAdd(SiteTree $record, Form $form) {
|
||||||
|
$data = $form->getData();
|
||||||
|
if(!isset($data['Locale'])) {
|
||||||
|
$data['Locale'] = Translatable::get_current_locale();
|
||||||
|
}
|
||||||
|
$record->Locale = $data['Locale'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user