We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36885
    • 15 Posts
    I got my php-code to fire up my different CMP pages according what I learned with: https://forums.modx.com/thread/74717/upgrade-of-cmp-to-2-2#dis-post-414436

    But now I am struggling to fill my panels with information.
    The panels have been changed so that they fit the 2.2 standard of showing CMP.
    But, I cannot get fields to be updated (it doesn't seem that the setup event is fired correctly.

    Here is copy-paste with the parts of 'index.class.php' that adds the record and further information:
    				$this->addHtml('
    					<script type="text/javascript">
    						// <![CDATA[
    						Ext.onReady(function() {
    							Liteauction.config = '.$this->modx->toJSON($this->liteauction->config).';
    							MODx.load({
            						xtype: "liteauction-page-home"
            						,auction: "'.$auctionItem->get('id').'"
            						,activetab: "'.$activeTab.'"
            						,defaultcurrencyid: "'.$defaultCurrencyId.'"
            						,defaultcurrencyname: "'.$defaultCurrencyName.'"
            						,defaultfontineditor: "'.$defaultFontInEditor.'"
            						,defaultcountryid: "'.$defaultCountryId.'"
            						,record: '.$this->modx->toJSON($auctionItemArray).'
        						});
    						});
    						// ]]>
    					</script>');
    			}


    'index.class.php' adds all js-files, and the section file 'index.auction.js' looks like the following:
    Liteauction.page.Home = function(config) {
    	config = config || {};
    	Ext.applyIf(config,{
    		formpanel: 'liteauction-panel-home'
            ,buttons: [{
                process: 'update'
                ,url: Liteauction.config.connectorUrl
                /* ,handler:function () { alert('Hello world); } */
                ,baseParams: { action: 'mgr/auction/update2' }
                ,text: _('save')
                ,method: 'remote'
                ,checkDirty: false
                ,keys: [{
                    key: MODx.config.keymap_save || 's'
                    ,alt: true
                    ,ctrl: true
                }]
            },'-',{
                process: 'cancel'
                ,text: _('liteauction.default_back')
                ,params: { a:MODx.action['liteauction:index'] }
            }]
    		,components: [{
    			xtype: 'liteauction-panel-home'
    			,renderTo: 'liteauction-panel-home-div'
    	        ,activetab: config.activetab
                ,defaultcurrencyid: config.defaultcurrencyid
                ,defaultcurrencyname: config.defaultcurrencyname
                ,defaultfontineditor: config.defaultfontineditor
                ,defaultcountryid: config.defaultcountryid
                ,record: config.record || {}
    		}]
    	});
    	Liteauction.page.Home.superclass.constructor.call(this,config);
    };
    
    Ext.extend(Liteauction.page.Home, MODx.Component);
    Ext.reg('liteauction-page-home', Liteauction.page.Home);


    The widget-file 'panel.auction.js' has the following code related to setup and other:
    Ext.extend(Liteauction.panel.Home, MODx.Panel, {
        initialized: false
        ,setup: function() {
            if (this.initialized) { this.clearDirty(); return true; }
            this.getForm().setValues(this.config.record);
            if (!Ext.isEmpty(this.config.record.name_1)) {
                Ext.getCmp('liteaction-header').getEl().update('<h2>'+_('liteauction.auction_tabname')+': '+this.config.record.name_1+' ('+this.config.record.id+')</h2>');
            }
            this.fireEvent('ready',this.config.record);
            this.clearDirty();
            this.initialized = true;
            MODx.fireEvent('ready');
            return true;
        }
    	,beforeSubmit: function(o) {
    	}
    	,success: function(o) {
    		Ext.Msg.Alert('Hello2');
    	}
    	,fieldChange: function() {
            if (Ext.getCmp('liteauction-auction-partnerowned').checked == true) {
            	Ext.getCmp('liteauction-auction-clientid').hide();
            	Ext.getCmp('liteauction-auction-ownercommtypeid').hide();
    		} else {
    			Ext.getCmp('liteauction-auction-clientid').show();
    			Ext.getCmp('liteauction-auction-ownercommtypeid').show();
    		}
    	}
    });
    Ext.reg('liteauction-panel-home', Liteauction.panel.Home);


    Now, why is not the fields filled with the record information? (= why is not the setup event fired). Have I missed something crucial?

    Have spent now a number of hours without going forward, I therefore ask the community for support as I am now stuck smiley

    Also, the 'update' button does not fire as remote and trigger any update.php. Can this also be linked to something wrong in the design to get CMP to correcty initialize and use Component -> Panel?

    Regards
    Sven