Merge pull request #231 from micmania1/cms-dependency

This commit is contained in:
Daniel Hensby 2016-03-07 15:37:43 +00:00
commit 1ad0d0b0a2

View File

@ -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'];
}
} }