<![CDATA[ Saving your CMP form using the page toolbar with the parameters "reload" and "process". - My Forums]]> https://forums.modx.com/thread/?thread=99673 <![CDATA[Re: Saving your CMP form using the page toolbar with the parameters "reload" and "process".]]> https://forums.modx.com/thread/99673/saving-your-cmp-form-using-the-page-toolbar-with-the-parameters-reload-and-process#dis-post-562990 did you found a solution for this issue?
]]>
dhsbernhard Nov 29, 2018, 04:16 PM https://forums.modx.com/thread/99673/saving-your-cmp-form-using-the-page-toolbar-with-the-parameters-reload-and-process#dis-post-562990
<![CDATA[Re: Saving your CMP form using the page toolbar with the parameters "reload" and "process".]]> https://forums.modx.com/thread/99673/saving-your-cmp-form-using-the-page-toolbar-with-the-parameters-reload-and-process#dis-post-539190 jeffmiranda Mar 03, 2016, 11:04 PM https://forums.modx.com/thread/99673/saving-your-cmp-form-using-the-page-toolbar-with-the-parameters-reload-and-process#dis-post-539190 <![CDATA[Re: Saving your CMP form using the page toolbar with the parameters "reload" and "process".]]> https://forums.modx.com/thread/99673/saving-your-cmp-form-using-the-page-toolbar-with-the-parameters-reload-and-process#dis-post-539187 BobRay Mar 03, 2016, 05:13 PM https://forums.modx.com/thread/99673/saving-your-cmp-form-using-the-page-toolbar-with-the-parameters-reload-and-process#dis-post-539187 <![CDATA[Saving your CMP form using the page toolbar with the parameters "reload" and "process".]]> https://forums.modx.com/thread/99673/saving-your-cmp-form-using-the-page-toolbar-with-the-parameters-reload-and-process#dis-post-539136
I've built a CMP that contains a form panel with some fields. The behaviour I'm looking for is similar to how MODX handles new resources or chunks, etc. namely that once the new element is saved, the page loads the update version of the form with the newly created element loaded.

Here is my page code:

Ext.onReady(function() {
    MODx.load({ xtype: 'pop-page-events-create-manifest' });
});
Pop.page.EventsCreateManifest = function(config) {
    config = config || {};
    Ext.applyIf(config,{
        formpanel: 'pop-panel-events-create-manifest'
        ,buttons: [{
            reload: true
            ,text: _('pop.save')
            ,id: 'pop-manifest-btn-save'
            ,cls: 'primary-button'
            ,process: 'mgr/events/popmanifestcreate'
            ,params: {
                namespace: 'popupstudio'
            }
            ,method: 'remote'
            ,keys: [{
                key: MODx.config.keymap_save || 's'
                ,ctrl: true
            }]
        },{
            text: _('pop.cancel')
            ,handler: function() {
	        	location.href = '?a=events/home&namespace=popupstudio&activeTab=2';
	        }
	        ,scope:this
        }]
        ,components: [{
            xtype: 'pop-panel-events-create-manifest'
            ,renderTo: 'pop-panel-events-create-manifest-div'
        }]
    });
    Pop.page.EventsCreateManifest.superclass.constructor.call(this,config);
};
Ext.extend(Pop.page.EventsCreateManifest,MODx.Component);
Ext.reg('pop-page-events-create-manifest',Pop.page.EventsCreateManifest);


I have the whole thing working except for the redirect. The page I keep getting redirected to is

http://mydomain:8080/manager/?a=mgr/events/popmanifestupdate&namespace=popupstudio&id=48

The page I want to get to is

http://mydomain:8080/manager/?a=events/updatemanifest&namespace=popupstudio&id=48

I looked at the code for modx.component.js and it seems that when reload is true, it's taking the process value, replacing "create" with "update" and the result is being used as the first parameter in a MODx.loadPage() call. Here are lines 322 to 330 of modx.component.js:

            var action;
            if (o.actions && o.actions.edit) {
                // If an edit action is given, use it (BC)
                action = o.actions.edit;
            } else {
                // Else assume we want the 'update' controller
                action = itm.process.replace('create', 'update');
            }
            MODx.loadPage(action, url);


Correct me if I'm wrong but what was once my processor call is now becoming my action call for my controller? Am I understanding this correctly? It's driving me crazy because the two aren't interchangeable. I mean, it works for elements like resources and the like but it doesn't really work for CMP namely because the processor calls usually have the "mgr/" prefix.

I guess I'm wondering if I'm going about this the right way. Should I continue to try and use the "reload" parameter or should I ditch that, and redirect on the form panel's success event and load the update form "manually"? Some guidance would be appreciated. I want to take advantage of the "MODX way" of doing things but it seems like this reload parameter is more trouble than it's worth.]]>
jeffmiranda Mar 03, 2016, 01:23 AM https://forums.modx.com/thread/99673/saving-your-cmp-form-using-the-page-toolbar-with-the-parameters-reload-and-process#dis-post-539136