We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36360
    • 7 Posts
    Hi,

    I’m trying to submit the form when the button is clicked, however it wasn’t as simple as i thought, i always end up getting a fp.getForm is not a function, although the submit handler is taken directly from the ExtJs doc, any clue?

    Players.panel.Subscription = function(config) {
        config = config || {};
        Ext.apply(config,{
            border: false
            ,baseCls: 'modx-formpanel'
            ,process: 'mgr/player/getSubscribers'
            ,standardSubmit: true
            ,url: Players.config.connectorUrl
            ,baseParams: { action: 'mgr/player/getSubscribers' }
            ,buttons: [{
                        text: 'Export er'
                        ,formBind: true
                        ,type: 'submit'
                        ,handler: function(){
    
    
                                var fp = this.ownerCt.ownerCt,
                                    form = fp.getForm();
                                if (form.isValid()) {
                                    // check if there are baseParams and if
                                    // hiddent items have been added already
                                    if (fp.baseParams && !fp.paramsAdded) {
                                        // add hidden items for all baseParams
                                        for (i in fp.baseParams) {
                                            fp.add({
                                                xtype: 'hidden',
                                                name: i,
                                                value: fp.baseParams[i]
                                            });
                                        }
                                        fp.doLayout();
                                        // set a custom flag to prevent re-adding
                                        fp.paramsAdded = true;
                                    }
                                    form.submit();
                                }
                        
                    }
                    }]
            
        });
        Players.panel.Subscription.superclass.constructor.call(this,config);
    };


    Thanks
      • 36360
      • 7 Posts
      It was actually because I was extending the wrong class, Panel instead of MODx.FormPanel, the problem now is the page is submitting to itself, although am sitting the url parameter correctly to my connector:

      Players.panel.Subscription = function(config) {
          config = config || {};
          Ext.apply(config,{
              id : 'players-subscription-home'
              ,border: false
              ,baseCls: 'modx-formpanel'
              ,standardSubmit: true
              ,baseParams: { action: 'mgr/player/getSubscribers' }
              ,url: Players.config.connectorUrl
              ,buttons: [{
                          text: 'Export Subscribers'
                          ,type: 'submit'
                          ,handler:  function(){
                                  var fp = this.ownerCt.ownerCt,
                                      form = fp.getForm();
                                      alert(fp.url);
                                  if (form.isValid()) {
                                      // check if there are baseParams and if
                                      // hiddent items have been added already
                                      if (fp.baseParams && !fp.paramsAdded) {
                                          // add hidden items for all baseParams
                                          for (i in fp.baseParams) {
                                              fp.add({
                                                  xtype: 'hidden',
                                                  name: i,
                                                  value: fp.baseParams[i]
                                              });
                                          }
                                          fp.doLayout();
                                          // set a custom flag to prevent re-adding
                                          fp.paramsAdded = true;
                                      }
                                      form.submit();
                                  }
                          
                      }
                      }]
              
          });
          Players.panel.Subscription.superclass.constructor.call(this,config);
      };
      
      Ext.extend(Players.panel.Subscription,MODx.FormPanel);
      Ext.reg('players-subscription-home',Players.panel.Subscription);
        • 18373 ☆ A M B ☆
        • 3,141 Posts
        I typically just use this.submit() or this.getForm().submit() depending where I call it from.

        That code (or something similar) is already in the loaded ExtJS and probably overriden by modExt.
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 36360
          • 7 Posts
          that’s what the code is basically, i’m just adding the baseparams as hidden text fields on the way because they are ignored when used in standardSubmit mode, not sure still why the form is submitting to itseld and not to the specified url