mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
Merge pull request #238 from christopherdarling/gridfieldfix
API Add support for gridfield
This commit is contained in:
commit
e84b61246e
@ -16,3 +16,7 @@ HtmlEditorField_Toolbar:
|
||||
DataQuery:
|
||||
extensions:
|
||||
['Translatable']
|
||||
|
||||
GridFieldDetailForm_ItemRequest:
|
||||
extensions:
|
||||
['TranslatableCMSMainExtension']
|
||||
|
@ -120,15 +120,25 @@ class TranslatableCMSMainExtension extends Extension {
|
||||
// persist in the database before the user requests it
|
||||
$translatedRecord = $record->createTranslation($langCode);
|
||||
|
||||
if ( $this->owner instanceof GridFieldDetailForm_ItemRequest ) {
|
||||
$controller = $this->owner->getController();
|
||||
|
||||
$this->owner->record = $translatedRecord;
|
||||
|
||||
$url = $this->owner->Link('edit');
|
||||
} else {
|
||||
$controller = $this->owner;
|
||||
|
||||
$url = Controller::join_links(
|
||||
$this->owner->Link('show'),
|
||||
$translatedRecord->ID
|
||||
);
|
||||
}
|
||||
|
||||
// set the X-Pjax header to Content, so that the whole admin panel will be refreshed
|
||||
$this->owner->getResponse()->addHeader('X-Pjax', 'Content');
|
||||
$controller->getResponse()->addHeader('X-Pjax', 'Content');
|
||||
|
||||
return $this->owner->redirect($url);
|
||||
return $controller->redirect($url);
|
||||
}
|
||||
|
||||
function updateLink(&$link) {
|
||||
|
@ -66,7 +66,7 @@
|
||||
* Requires:
|
||||
* jquery.metadata
|
||||
*/
|
||||
$('.LeftAndMain :input[name=action_createtranslation]').entwine({
|
||||
$(':input[name=action_createtranslation]').entwine({
|
||||
|
||||
onclick: function(e) {
|
||||
this.parents('form').trigger('submit', [this]);
|
||||
|
Loading…
Reference in New Issue
Block a user