We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34127
    • 135 Posts
    Hey guys, I’ve been having some trouble getting my FormPanel to submit in one of my components. I’ve modeled the panel after the one used on the Resource create/edit page in the manager, and I have a set of buttons (Save, Delete, Cancel) at the top of the page. Save and Delete don’t appear to be firing any events. Firebug nor the FF console is displaying any errors, so I’m pretty confused. I’ve made sure that the "formpanel" option in the page object is correct, and I can’t see anything that might be preventing the submit event from firing. Any help would be greatly appreciated!

    Here’s the code for the page display:
    SubmitStuff.page.ItemData = function( config ) {
        config = config || {};
        
        Ext.applyIf( config, {
            url : SubmitStuff.config.connectorsPath + "itemdb.php",
            formpanel: "submitstuff-panel-item-data",
            components: [ {            
                xtype : "submitstuff-panel-item-data",
                renderTo : "submitstuff-panel-item-data",
                id : config.id
            } ],
            buttons: [ {
                process : "update",
                text : _( "save" ),
                method : "remote"
            }, "-", {
                process : "remove",
                text : _( "delete" ),
                method : "remote",
                confirm : _( "remove_sub_conf" )
            }, "-", {
                processs : "cancel",
                text : _( "cancel" ),
                params : {
                    a : MODx.action["controllers/submitstuff.list"]
                }
            } ]
        } );
        
        SubmitStuff.page.ItemData.superclass.constructor.call( this, config );
    };
    Ext.extend( SubmitStuff.page.ItemData, MODx.Component );
    Ext.reg( "submitstuff-page-item-data", SubmitStuff.page.ItemData );


    And the code for the actual FormPanel (removed most of the fields and unnecessary stuff):
    SubmitStuff.panel.ItemData = function( config ) {
        config = config || {};
        
        Ext.applyIf( config, {
            url : SubmitStuff.config.connectorsPath + "itemdb.php",
            baseParams : {},
            id : "submitstuff-panel-item-data",
            labelAlign : "left",
            labelWidth : 145,
            defaults : {
                collapsible : true,
                autoHeight : true
            },
            items : [ {
                html : "<h2>" + _( "itemdb_sub" ) + "</h2>",
                id : "submitstuff-item-header",
                cls : "modx-page-header",
                border : false
            }, {
                xtype : "portal",
                items : [ {
                    columnWidth: .98,
                    items : [ {
                        title : _( "sub_content" ),
                        layout : "form",
                        defaults : {
                            border : false,
                            msgTarget : "side"
                        },
                        items: [ {
                            xtype : "hidden",
                            id : "item-sid",
                            name : "id",
                            value : config.id
                        }, {
                            xtype : "statictextfield",
                            fieldLabel : _( "item_id" ),
                            description : _( "desc_item_id"),
                            id : "item-id",
                            name : "item_id"
                        }, {
                            xtype : "textfield",
                            fieldLabel : _( "item_name" ),
                            description : _( "desc_item_name"),
                            id : "item-name",
                            name : "name"
                        } ]
                    } ]
                } ]
            } ],
            listeners : {
                "setup" : {
                    fn : this.setup, 
                    scope : this
                },
                "beforeSubmit" : {
                    fn : this.beforeSubmit, 
                    scope : this
                },
                "success" : {
                    fn : this.success, 
                    scope : this
                }
            }
        } );
        
        SubmitStuff.panel.ItemData.superclass.constructor.call( this, config );
    };
    Ext.extend( SubmitStuff.panel.ItemData, MODx.FormPanel, {
        setup : function() {
            
        },
        success : function( o ) {
            
        },
        beforeSubmit : function( o ) {
            
        }
    } );
    Ext.reg( "submitstuff-panel-item-data", SubmitStuff.panel.ItemData );
    


    Thanks for any help you guys can give me!
      • 21257 MODX Staff
      • 730 Posts
      Did you actually define your own custom x-type of "submitstuff-panel-item-data"?
        Mike Schell
        Lead Developer, MODX Cloud
        Email: [email protected]
        GitHub: https://github.com/netProphET/
        Twitter: @mkschell
        • 28215
        • 4,149 Posts
        A few things:

        1) When passing into your panel, make sure your primary key is not "id" (i realize some MODExt forms in the manager do this; they need to be fixed). i.e., these lines:

        [{            
                xtype : "submitstuff-panel-item-data",
                renderTo : "submitstuff-panel-item-data",
                id : config.id
        }]


        Should be:

        [{            
                xtype : "submitstuff-panel-item-data",
                renderTo : "submitstuff-panel-item-data",
                item : config.item
        }]


        Why? Because otherwise, it’s going to override this following line, and make the DOM ID of your panel be the Item id:

        id : "submitstuff-panel-item-data",


        So, change it to item, and then change the code in the panel accordingly (ie, value: config.item instead of value: config.id).


        Also, always make sure to fire the ready event in your setup: function.

        this.fireEvent('ready',{ /* optional data obj here */ });



        If that doesn’t work, let me know.
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 34127
          • 135 Posts
          Thanks Shaun, that worked! I had no idea that "id" field/pk would cause an issue... I knew it had to be something trivial like that. tongue I’ve been at it for two days without any luck - you’re a lifesaver. laugh

          While totally unrelated to Ext, I just had a quick question about packaging actions... this action isn’t attached to a menu, and in my transport script I have this:

          $attr = array(
              ...
              'action-nomenu' => array (
                  XPDO_TRANSPORT_PRESERVE_KEYS                => false,
                  XPDO_TRANSPORT_UPDATE_OBJECT                => true,
                  XPDO_TRANSPORT_UNIQUE_KEY                   => array ( 'namespace', 'controller' ),
                  XPDO_TRANSPORT_RELATED_OBJECTS              => false
              ),
              ....
          );
          
          $action = $modx->newObject( 'modAction' );
          $action->set( 'namespace', 'submitstuff' );
          $action->set( 'parent', 0 );
          $action->set( 'controller', 'controllers/submitstuff.itemview' );
          $action->set( 'haslayout', 1 );
          $action->set( 'lang_topics', 'submitstuff:itemdb' );
          $action->set( 'assets', '' );
          $actionVehicle = $builder->createVehicle( $action, $attr['action-nomenu'] );
          $builder->putVehicle( $actionVehicle );


          It builds just fine, but when I install it using the package manager, I get an error along the lines of "could not install related objects for vehicle" (the wording isn’t exact). The action does get installed, but I wonder if maybe I’m just missing something here? Shouldn’t the "XPDO_TRANSPORT_RELATED_OBJECTS" set to false prevent it from looking for any "attached"objects? When I remove the action vehicle it works fine.

          Thanks again!
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: Ricjustsaid at Mar 31, 2009, 10:41 AM

            It builds just fine, but when I install it using the package manager, I get an error along the lines of "could not install related objects for vehicle" (the wording isn’t exact). The action does get installed, but I wonder if maybe I’m just missing something here? Shouldn’t the "XPDO_TRANSPORT_RELATED_OBJECTS" set to false prevent it from looking for any "attached"objects? When I remove the action vehicle it works fine.
            Try leaving out the XPDO_TRANSPORT_RELATED_OBJECTS => false and see. It may be that the presence of the key in the attributes is making it attempt to install them, even though the value is false.
              • 34127
              • 135 Posts
              Quote from: OpenGeek at Mar 31, 2009, 10:53 AM

              Quote from: Ricjustsaid at Mar 31, 2009, 10:41 AM

              It builds just fine, but when I install it using the package manager, I get an error along the lines of "could not install related objects for vehicle" (the wording isn’t exact). The action does get installed, but I wonder if maybe I’m just missing something here? Shouldn’t the "XPDO_TRANSPORT_RELATED_OBJECTS" set to false prevent it from looking for any "attached"objects? When I remove the action vehicle it works fine.
              Try leaving out the XPDO_TRANSPORT_RELATED_OBJECTS => false and see.  It may be that the presence of the key in the attributes is making it attempt to install them, even though the value is false.
              That did it, thanks a bunch Jason! Even though the error didn’t actually effect the install, that error was driving my crazy not knowing what was wrong. tongue