mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #464 from mateusz/os7299
BUGFIX: add capability of redirecting form actions.
This commit is contained in:
commit
3f932d6bad
@ -106,7 +106,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
);
|
||||
|
||||
/**
|
||||
* @var PJAXResponseNegotiator
|
||||
* @var PjaxResponseNegotiator
|
||||
*/
|
||||
protected $responseNegotiator;
|
||||
|
||||
@ -416,12 +416,12 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
/**
|
||||
* Caution: Volatile API.
|
||||
*
|
||||
* @return PJAXResponseNegotiator
|
||||
* @return PjaxResponseNegotiator
|
||||
*/
|
||||
public function getResponseNegotiator() {
|
||||
if(!$this->responseNegotiator) {
|
||||
$controller = $this;
|
||||
$this->responseNegotiator = new PJAXResponseNegotiator(array(
|
||||
$this->responseNegotiator = new PjaxResponseNegotiator(array(
|
||||
'CurrentForm' => function() use(&$controller) {
|
||||
return $controller->getEditForm()->forTemplate();
|
||||
},
|
||||
|
@ -80,10 +80,18 @@
|
||||
// as automatic browser ajax response redirects seem to discard the hash/fragment.
|
||||
formData.push({name: 'BackURL', value:History.getPageUrl()});
|
||||
|
||||
// Some action buttons are redirecting to content areas as oposed to reloading the form.
|
||||
// They will have pjax-content class on them.
|
||||
var pjaxType = 'CurrentForm', pjaxSelector = '.cms-edit-form';
|
||||
if ($(button).hasClass('pjax-content')) {
|
||||
pjaxType = 'Content';
|
||||
pjaxSelector = '.cms-content';
|
||||
}
|
||||
|
||||
jQuery.ajax(jQuery.extend({
|
||||
headers: {
|
||||
"X-Pjax" : "CurrentForm",
|
||||
'X-Pjax-Selector': '.cms-edit-form'
|
||||
"X-Pjax" : pjaxType,
|
||||
'X-Pjax-Selector': pjaxSelector
|
||||
},
|
||||
url: form.attr('action'),
|
||||
data: formData,
|
||||
|
@ -291,8 +291,9 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
|
||||
if($this->record->ID !== 0) {
|
||||
$actions->push(FormAction::create('doSave', _t('GridFieldDetailForm.Save', 'Save'))
|
||||
->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
|
||||
// The delete action will redirect, hence pjax-content class.
|
||||
$actions->push(FormAction::create('doDelete', _t('GridFieldDetailForm.Delete', 'Delete'))
|
||||
->addExtraClass('ss-ui-action-destructive'));
|
||||
->addExtraClass('ss-ui-action-destructive')->addExtraClass('pjax-content'));
|
||||
}else{ // adding new record
|
||||
//Change the Save label to 'Create'
|
||||
$actions->push(FormAction::create('doSave', _t('GridFieldDetailForm.Create', 'Create'))
|
||||
|
Loading…
Reference in New Issue
Block a user