We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40715
    • 13 Posts
    I am creating a CMP that showing a list of resources in grid format

    i already created the create class of processor , and i would like to redirect to editing page when success , but i cannot get the newly inserted resource id , how can i get it ??


     Product.window.CreateProduct = function(config) {
        config = config || {};
        Ext.applyIf(config,{
            title: _('product.product_create')
            ,url: Product.config.connectorUrl
            ,baseParams: {
                action: 'mgr/product/create'
            }
            ,fields: [{
                xtype: 'textfield'
                ,fieldLabel: _('product.name')
                ,name: 'pagetitle'
                ,anchor: '100%'
            },{
                xtype: 'textarea'
                ,fieldLabel: _('product.description')
                ,name: 'description'
                ,anchor: '100%'
            } 
    		
    		] , success: function(o){
    		 
    			location.href='?a=30&id='+o.result.object.id;
    				  
    			 
    		},
        });
        Product.window.CreateProduct.superclass.constructor.call(this,config);
    };
      • 33976 ☆ A M B ☆
      • 571 Posts
      Hi,

      At first glance it looks like correct. You can console.log(o) to make sure you've got the right data.
      Also your processor must return the newly created object, so as far as i remind :

      public function cleanup() {
          return $this->success('Optional message', $this->object);
      }
      


      Hope that will help
        • 40715
        • 13 Posts
        Thanks!

        but the object "o" return a very very complex and long object that i really hard to get the ID from ...
          • 40715
          • 13 Posts
          and finally i found

          o.items.items[0].events.hide.listeners[0].scope.container.initialConfig.errorReader.jsonData.object.id


          but it seems stupid way , any other better way to get the object id / details ??