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