Merged [47007]: Fix to prevent GenericDataAdmin setting a status on a new record and thus overwritting a data field named 'Status'. Includes a fix for onclick on Ajax buttons if event is not passed.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@60167 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Hayden Smith 2008-08-08 04:29:32 +00:00
parent 4b5ab8a997
commit 438b6b5f85
2 changed files with 7 additions and 3 deletions

View File

@ -475,10 +475,10 @@ HTML;
if(substr($id, 0, 3) != 'new') {
$generic = DataObject::get_one($className, "`$className`.ID = $id");
$generic->Status = "Saved (Update)";
$generic->__Status = "Saved (Update)";
} else {
$generic = new $className();
$generic->Status = "Saved (New)";
$generic->__Status = "Saved (New)";
}
$form->saveInto($generic, true);
@ -497,7 +497,7 @@ HTML;
}
$this->getActionUpdateJS($generic);
FormResponse::status_message(_t('GenericDataAdmin.SAVED', 'Saved'), 'good');
FormResponse::update_status($generic->Status);
FormResponse::update_status($generic->__Status);
if (method_exists($this, "saveAfterCall")) {
$this->saveAfterCall($generic, $urlParams, $form);
@ -537,6 +537,9 @@ HTML;
$form->saveInto($obj);
$obj->write();
// This appears to be a typo. There is no 'urlParms'.
// $this->urlParms['ID'] = $obj->ID;
$editForm = $this->getEditForm($obj->ID);
return (Director::is_ajax()) ? $editForm->formHtmlContent() : array ('EditForm' => $editForm);

View File

@ -274,6 +274,7 @@ function prepareAjaxActions(actions, formName, tabName) {
button.ownerForm = $(formName);
button.onclick = function(e) {
if(!e) e = window.event;
// tries to call a custom method of the format "action_<youraction>_right"
if(window[this.name + '_' + tabName]) {
window[this.name + '_' + tabName](e);