I've got a custom SiteConfig extension where I put some kind of category links in. Now, I installed the translatable module and finished almost everything but can't get my own SiteConfig to save the proper locale. All items are stored as 'de_DE' – even though the URL is at: /admin/settings/EditForm/field/CatLinks/item/new?locale=en_GB&locale=en_GB
When I save the record it is stored as 'de_DE'.
There are those two classes:
class CatLinks extends DataObject {
static $singular_name = "Cat-Links";
public static $db = array(
'name' => 'Varchar(255)',
'description' => 'Varchar(255)',
'urlLink' => 'Varchar(255)',
'SortOrder' => 'Int'
);
public function getCMSFields() {
return new FieldList(
new TextField(
'name',
'Category'
),
new TextField(
'description',
'Description'
),
new TextField(
'urlLink',
'URL'
)
);
}
}
and
<?php
class CustomSiteConfig extends DataExtension {
function initNavigationGridField() {
$displayColumns = new GridFieldDataColumns();
$displayColumns->setDisplayFields(
array(
'name' => 'Name',
'description' => 'Description',
'urlLink' => 'URL'
)
);
$gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldToolbarHeader(),
new GridFieldAddNewButton('toolbar-header-right'),
new GridFieldPaginator(8),
$displayColumns,
new GridFieldEditButton(),
new GridFieldDeleteAction(),
new GridFieldDetailForm()
);
$gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
$gridField = new GridField('CatLinks', 'CatLinks', new DataList('CatLinks'), $gridFieldConfig);
return $gridField;
}
public function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab("Root.Produktkategorien", $this->initNavigationGridField());
return $fields;
}
function getCatLinks() {
$NavigationObject = DataObject::get("CatLinks");
$NavigationObject->sort('SortOrder');
return $NavigationObject;
}
}
How do I say SilverStripe to save the locale correctly? Where do I have to look at the docs/module?
Anybody knows what's the problem?
##
I added
new HiddenField( $name='Locale', $title='LocaleTitle', $value=Translatable::get_current_locale() )
to getCMSFields() and noticed that there is a hidden field, but it is set to de_DE. When I change the $name to 'Locale2' for example the hidden field changes to <input type="hidden" name="Locale2" value="en_GB" class="hidden" id="Form_ItemEditForm_Locale2">
Somewhere my locale variable gets a new value.