mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
updating form in ctf-popup after saving (including validation-errors and fields that have may changed on the serverside, e.g. ImageField)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@48867 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
0672ce2d0a
commit
d28faae514
@ -333,7 +333,6 @@ JS;
|
||||
|
||||
if (is_numeric($childID)) {
|
||||
if ($this->methodName == "show" || $this->methodName == "edit") {
|
||||
|
||||
$form->loadDataFrom($childData);
|
||||
}
|
||||
}
|
||||
@ -767,8 +766,14 @@ class ComplexTableField_Popup extends Form {
|
||||
$this->saveInto($childObject);
|
||||
$childObject->write();
|
||||
|
||||
// if ajax-call in an iframe, close window by javascript, else redirect to referrer
|
||||
if(!Director::is_ajax()) {
|
||||
if(Director::is_ajax()) {
|
||||
// if ajax-call in an iframe, update window
|
||||
$form = $this->controller->DetailForm();
|
||||
$form->loadDataFrom($childObject);
|
||||
FormResponse::update_dom_id($form->FormName(), $form->formHtmlContent(), true, 'update');
|
||||
return FormResponse::respond();
|
||||
} else {
|
||||
// else redirect to referrer
|
||||
Director::redirect(substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'],"?")));
|
||||
}
|
||||
}
|
||||
|
@ -23,13 +23,12 @@ ComplexTableFieldPopupForm.prototype = {
|
||||
// only do ajaxy stuff for content loaded in an iframe
|
||||
if(window != top && parent.parent.GB_hide) {
|
||||
var theForm = Event.findElement(e,"form");
|
||||
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
||||
if(parent.parent.statusMessage != undefined) parent.parent.statusMessage('saving');
|
||||
submitButton.setAttribute("disabled","true");
|
||||
|
||||
submitButton._oldValue = submitButton.value;
|
||||
submitButton.value = ingize(submitButton.value);
|
||||
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
||||
if(typeof submitButton != 'undefined') {
|
||||
submitButton.disabled = true;
|
||||
Element.addClassName(submitButton,'loading');
|
||||
}
|
||||
|
||||
new parent.parent.Ajax.Request(
|
||||
theForm.getAttribute("action"),
|
||||
@ -48,6 +47,7 @@ ComplexTableFieldPopupForm.prototype = {
|
||||
|
||||
updateTableAfterSave : function(response) {
|
||||
eval(response.responseText);
|
||||
|
||||
var theForm = document.getElementsByTagName("form")[0];
|
||||
|
||||
// don't update when validation is present and failed
|
||||
@ -60,18 +60,20 @@ ComplexTableFieldPopupForm.prototype = {
|
||||
}
|
||||
);
|
||||
} else {
|
||||
var submitbutton = document.getElementsBySelector("input.action",theForm)[0];
|
||||
submitbutton.disabled = false;
|
||||
submitButton.value = submitButton._oldValue;
|
||||
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
||||
if(typeof submitButton != 'undefined') {
|
||||
submitButton.disabled = false;
|
||||
Element.removeClassName(submitButton,'loading');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
ajaxErrorHandler: function(response) {
|
||||
var submitButton = document.getElementsBySelector("form input.action")[0];
|
||||
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
||||
if(typeof submitButton != 'undefined') {
|
||||
submitButton.disabled = false;
|
||||
submitButton.value = submitButton._oldValue;
|
||||
Element.removeClassName(submitButton,'loading');
|
||||
}
|
||||
|
||||
// TODO does not work due to sandbox-iframe restrictions?
|
||||
if(typeof(parent.parent.ajaxErrorHandler) == 'function') {
|
||||
@ -85,9 +87,10 @@ ComplexTableFieldPopupForm.prototype = {
|
||||
var theForm =document.getElementsByTagName("form")[0];
|
||||
|
||||
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
||||
if(typeof submitButton != 'undefined') {
|
||||
submitButton.disabled = false;
|
||||
submitButton.value = submitButton._oldValue;
|
||||
Element.removeClassName(submitButton,'loading');
|
||||
}
|
||||
|
||||
// TODO Fix DOM-relation after pagination inside popup
|
||||
if(this.GB_OpenerObj) {
|
||||
|
Loading…
Reference in New Issue
Block a user