mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-29 20:59:23 +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 (is_numeric($childID)) {
|
||||||
if ($this->methodName == "show" || $this->methodName == "edit") {
|
if ($this->methodName == "show" || $this->methodName == "edit") {
|
||||||
|
|
||||||
$form->loadDataFrom($childData);
|
$form->loadDataFrom($childData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -767,8 +766,14 @@ class ComplexTableField_Popup extends Form {
|
|||||||
$this->saveInto($childObject);
|
$this->saveInto($childObject);
|
||||||
$childObject->write();
|
$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'],"?")));
|
Director::redirect(substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'],"?")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,13 @@ ComplexTableFieldPopupForm.prototype = {
|
|||||||
// only do ajaxy stuff for content loaded in an iframe
|
// only do ajaxy stuff for content loaded in an iframe
|
||||||
if(window != top && parent.parent.GB_hide) {
|
if(window != top && parent.parent.GB_hide) {
|
||||||
var theForm = Event.findElement(e,"form");
|
var theForm = Event.findElement(e,"form");
|
||||||
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
|
||||||
if(parent.parent.statusMessage != undefined) parent.parent.statusMessage('saving');
|
if(parent.parent.statusMessage != undefined) parent.parent.statusMessage('saving');
|
||||||
submitButton.setAttribute("disabled","true");
|
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
||||||
|
if(typeof submitButton != 'undefined') {
|
||||||
|
submitButton.disabled = true;
|
||||||
|
Element.addClassName(submitButton,'loading');
|
||||||
|
}
|
||||||
|
|
||||||
submitButton._oldValue = submitButton.value;
|
|
||||||
submitButton.value = ingize(submitButton.value);
|
|
||||||
Element.addClassName(submitButton,'loading');
|
|
||||||
|
|
||||||
new parent.parent.Ajax.Request(
|
new parent.parent.Ajax.Request(
|
||||||
theForm.getAttribute("action"),
|
theForm.getAttribute("action"),
|
||||||
{
|
{
|
||||||
@ -48,6 +47,7 @@ ComplexTableFieldPopupForm.prototype = {
|
|||||||
|
|
||||||
updateTableAfterSave : function(response) {
|
updateTableAfterSave : function(response) {
|
||||||
eval(response.responseText);
|
eval(response.responseText);
|
||||||
|
|
||||||
var theForm = document.getElementsByTagName("form")[0];
|
var theForm = document.getElementsByTagName("form")[0];
|
||||||
|
|
||||||
// don't update when validation is present and failed
|
// don't update when validation is present and failed
|
||||||
@ -60,18 +60,20 @@ ComplexTableFieldPopupForm.prototype = {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
var submitbutton = document.getElementsBySelector("input.action",theForm)[0];
|
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
||||||
submitbutton.disabled = false;
|
if(typeof submitButton != 'undefined') {
|
||||||
submitButton.value = submitButton._oldValue;
|
submitButton.disabled = false;
|
||||||
Element.removeClassName(submitButton,'loading');
|
Element.removeClassName(submitButton,'loading');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ajaxErrorHandler: function(response) {
|
ajaxErrorHandler: function(response) {
|
||||||
var submitButton = document.getElementsBySelector("form input.action")[0];
|
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
||||||
submitButton.disabled = false;
|
if(typeof submitButton != 'undefined') {
|
||||||
submitButton.value = submitButton._oldValue;
|
submitButton.disabled = false;
|
||||||
Element.removeClassName(submitButton,'loading');
|
Element.removeClassName(submitButton,'loading');
|
||||||
|
}
|
||||||
|
|
||||||
// TODO does not work due to sandbox-iframe restrictions?
|
// TODO does not work due to sandbox-iframe restrictions?
|
||||||
if(typeof(parent.parent.ajaxErrorHandler) == 'function') {
|
if(typeof(parent.parent.ajaxErrorHandler) == 'function') {
|
||||||
@ -85,9 +87,10 @@ ComplexTableFieldPopupForm.prototype = {
|
|||||||
var theForm =document.getElementsByTagName("form")[0];
|
var theForm =document.getElementsByTagName("form")[0];
|
||||||
|
|
||||||
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
var submitButton = document.getElementsBySelector("input.action",theForm)[0];
|
||||||
submitButton.disabled = false;
|
if(typeof submitButton != 'undefined') {
|
||||||
submitButton.value = submitButton._oldValue;
|
submitButton.disabled = false;
|
||||||
Element.removeClassName(submitButton,'loading');
|
Element.removeClassName(submitButton,'loading');
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Fix DOM-relation after pagination inside popup
|
// TODO Fix DOM-relation after pagination inside popup
|
||||||
if(this.GB_OpenerObj) {
|
if(this.GB_OpenerObj) {
|
||||||
|
Loading…
Reference in New Issue
Block a user