Just had to do the very thing!!
Add listeners to the Modx.FormPanel object that has the state buttons for the 'actionNew', 'actionContinue' and 'actionClose' events. (here is an example of the listeners)
,listeners: {
'setup': {fn:this.setup,scope:this}
,'success': {fn:this.success,scope:this}
,'failure': {fn:this.failure,scope:this}
,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
,'actionNew': {fn:this.actionRedirect,scope:this}
,'actionContinue': {fn:this.actionRedirect,scope:this}
,'actionClose': {fn:this.actionRedirect,scope:this}
}
Then add the appropriate function to deal with the event. (here is an example)
actionRedirect: function() {
var stay = Ext.state.Manager.get('modx.stay.'+MODx.request.a,'stay');
switch (stay) {
case 'new':
location.href = '?a='+MODx.request.a+'&action=create';
break;
case 'stay':
location.href = '?a='+MODx.request.a+'&action=update';
break;
default:
location.href = '?a='+MODx.request.a;
};
OR
Just add the logic from the action redirect function to the 'success' handler where you have the success object available to grab the new resource ID or whatever you've returned. (here is an example)
success: function(o) {
this.getForm().setValues(o.result.object);
var stay = Ext.state.Manager.get('modx.stay.'+MODx.request.a,'stay');
switch (stay) {
case 'new':
location.href = '?a='+MODx.request.a+'&action=create';
break;
case 'stay':
location.href = '?a='+MODx.request.a+'&action=update&id='+o.result.object.id;
break;
default:
location.href = '?a='+MODx.request.a;
};
Edit: I've removed the console.log that Lucas spotted!!
[ed. note: simonp98 last edited this post 14 years, 11 months ago.]