MINOR Using Form->forTemplate() to include <form> tags in controller actions on AssetAdmin and CMSMain (underlying clientside logic has changed)

This commit is contained in:
Ingo Schommer 2011-06-08 11:30:54 +12:00
parent 75ce441348
commit c4c3d21fa9
5 changed files with 25 additions and 18 deletions

View File

@ -358,7 +358,7 @@ JS
return $record->ID; return $record->ID;
} else if($this->isAjax()) { } else if($this->isAjax()) {
$form = $this->getEditForm($record->ID); $form = $this->getEditForm($record->ID);
return $form->formHtmlContent(); return $form->forTemplate();
} else { } else {
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID)); return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
} }

View File

@ -345,7 +345,7 @@ JS;
$this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP')); $this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP'));
return $form->formHtmlContent(); return $form->forTemplate();
} }
/** /**
* Get a database record to be managed by the CMS * Get a database record to be managed by the CMS
@ -578,7 +578,7 @@ JS;
$form = $this->getEditForm($record->ID); $form = $this->getEditForm($record->ID);
} }
return $form->formHtmlContent(); return $form->forTemplate();
} }
@ -615,7 +615,7 @@ JS;
return $record->ID; return $record->ID;
} else if(Director::is_ajax()) { } else if(Director::is_ajax()) {
$form = $this->getEditForm($record->ID); $form = $this->getEditForm($record->ID);
return $form->formHtmlContent(); return $form->forTemplate();
} else { } else {
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID)); return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
} }
@ -757,7 +757,7 @@ JS;
$form = $this->getEditForm($record->ID); $form = $this->getEditForm($record->ID);
return $form->formHtmlContent(); return $form->forTemplate();
} }
/** /**
@ -791,7 +791,7 @@ JS;
'Live', 'Live',
"\"SiteTree_Live\".\"ID\" = $recordID" "\"SiteTree_Live\".\"ID\" = $recordID"
); );
return ($liveRecord) ? $form->formHtmlContent() : ""; return ($liveRecord) ? $form->forTemplate() : "";
} else { } else {
$this->redirectBack(); $this->redirectBack();
} }
@ -988,7 +988,7 @@ JS;
$form = $this->getEditForm($record->ID); $form = $this->getEditForm($record->ID);
return $form->formHtmlContent(); return $form->forTemplate();
} }
function publish($data, $form) { function publish($data, $form) {
@ -1013,7 +1013,7 @@ JS;
// Reload form, data and actions might have changed // Reload form, data and actions might have changed
$form = $this->getEditForm($record->ID); $form = $this->getEditForm($record->ID);
return $form->formHtmlContent(); return $form->forTemplate();
} }
function performRollback($id, $version) { function performRollback($id, $version) {
@ -1187,7 +1187,7 @@ JS;
} }
if($this->isAjax()) { if($this->isAjax()) {
return $form->formHtmlContent(); return $form->forTemplate();
} else { } else {
$templateData = $this->customise(array( $templateData = $this->customise(array(
"EditForm" => $form "EditForm" => $form
@ -1426,7 +1426,7 @@ JS;
// Reload form, data and actions might have changed // Reload form, data and actions might have changed
$form = $this->getEditForm($restoredPage->ID); $form = $this->getEditForm($restoredPage->ID);
return $form->formHtmlContent(); return $form->forTemplate();
} }
function duplicate($request) { function duplicate($request) {
@ -1450,7 +1450,7 @@ JS;
// Reload form, data and actions might have changed // Reload form, data and actions might have changed
$form = $this->getEditForm($newPage->ID); $form = $this->getEditForm($newPage->ID);
return $form->formHtmlContent(); return $form->forTemplate();
} else { } else {
user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING); user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING);
} }
@ -1471,7 +1471,7 @@ JS;
// Reload form, data and actions might have changed // Reload form, data and actions might have changed
$form = $this->getEditForm($newPage->ID); $form = $this->getEditForm($newPage->ID);
return $form->formHtmlContent(); return $form->forTemplate();
} else { } else {
user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING); user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING);
} }

View File

@ -13,8 +13,12 @@ class CMSPagesController extends CMSMain {
} }
function show($request) { function show($request) {
$c = new CMSPageEditController(); if($request->param('ID')) {
return $this->redirect(Controller::join_links($c->Link('show'), $request->param('ID'))); $c = new CMSPageEditController();
return $this->redirect(Controller::join_links($c->Link('show'), $request->param('ID')));
} else {
return parent::show($request);
}
} }
} }

View File

@ -47,7 +47,7 @@
var currNode = $('.cms-tree')[0].firstSelected(); var currNode = $('.cms-tree')[0].firstSelected();
if(currNode) { if(currNode) {
var url = $(currNode).find('a').attr('href'); var url = $(currNode).find('a').attr('href');
$('.cms-edit-form').loadForm(url); $('.cms-content').loadForm(url);
} }
$('.cms-tree')[0].setCustomURL('admin/assets/getsubtree'); $('.cms-tree')[0].setCustomURL('admin/assets/getsubtree');
$('.cms-tree')[0].reload({onSuccess: function() { $('.cms-tree')[0].reload({onSuccess: function() {

View File

@ -201,8 +201,9 @@
if (e.button!=2) { if (e.button!=2) {
var $link = $(this); var $link = $(this);
$link.addClass('loading'); $link.addClass('loading');
jQuery('.cms-edit-form').entwine('ss').loadForm( jQuery('.cms-content').entwine('ss').loadForm(
$(this).attr('href'), $(this).attr('href'),
null,
function(e) { function(e) {
$link.removeClass('loading'); $link.removeClass('loading');
} }
@ -263,8 +264,9 @@
var link = $(this).siblings('.versionlink').find('a').attr('href'); var link = $(this).siblings('.versionlink').find('a').attr('href');
td.addClass('loading'); td.addClass('loading');
jQuery('.cms-edit-form').entwine('ss').loadForm( jQuery('.cms-content').entwine('ss').loadForm(
link, link,
null,
function(e) { function(e) {
td.removeClass('loading'); td.removeClass('loading');
} }
@ -314,8 +316,9 @@
data.push({name:$button.attr('name'), value: $button.val()}); data.push({name:$button.attr('name'), value: $button.val()});
if(loadEditForm) { if(loadEditForm) {
jQuery('.cms-edit-form').entwine('ss').loadForm( jQuery('.cms-content').entwine('ss').loadForm(
this.attr('action'), this.attr('action'),
null,
function(e) { function(e) {
$button.removeClass('loading'); $button.removeClass('loading');
}, },