On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • First off, the url and baseParams need to be rewritten if anyone plans on using mxFormBuilder in MODX 2.3. Simple enough fix.

    Anywhere you find
    url: MODx.config.connector_url+'folder/some_connector.php',
    baseParams: { action: 'getlist'},


    you will need to change to
        	,url: MODx.config.connector_url
            ,baseParams: {
                action: 'folder/some_connector/getlist'
            }
    


    This is due to the way 2.3 handles connectors from what I have gathered on the forums.

    Another thing that has to change for the SuperBoxSelect to show up properly in mxfb is the class.

            ,clearBtnCls: 'x-form-trigger'
            ,expandBtnCls: 'x-form-trigger'
    

    needs to be added (and any other old tagClass needs to be removed) so that the select box renders properly in 2.3.

    Here is my refactored code to get the Users superselectbox working in 2.3:
    MODx.combo.Users = function (config, getStore) {
        config = config || {};
        Ext.applyIf(config, {
            name: 'fake_users'
            ,hiddenName: 'fake_users'
            ,valueField: "id"
            ,displayField: "username"
            ,mode: 'remote'
            ,triggerAction: 'all'
            ,typeAhead: true
            ,editable: true
            ,forceSelection: false
            ,clearBtnCls: 'x-form-trigger'
            ,expandBtnCls: 'x-form-trigger'
        	,xtype:'superboxselect'
        	,url: MODx.config.connector_url
            ,baseParams: {
                action: 'security/user/getlist'
            }
            ,fields: ['username', 'id']
        });
        Ext.applyIf(config,{
            
    	store: new Ext.data.JsonStore({
    	    url: config.url
                ,root: 'results'
                ,fields: config.fields
                ,errorReader: MODx.util.JSONReader
                ,baseParams: config.baseParams || {}
                ,remoteSort: config.remoteSort || false
                ,autoDestroy: true
    	,listeners: {
                        'load': {fn:function(store, records, options ) {
                        }}
                        ,scope : this
                    }
    	})
            ,listeners: {
                'beforeselect': {fn:function(combo, record, index ) {
                    if (record.data.is_parent == '1'){
                        return false;
                    }
                }}
                ,scope : this
            }  
        });
        if (getStore === true) {
            config.store.load();
            return config.store;
        }
        MODx.combo.Users.superclass.constructor.call(this, config);
        this.config = config;
        return this;
    };
    Ext.extend(MODx.combo.Users, Ext.ux.form.SuperBoxSelect);
    Ext.reg('modx-superbox-user', MODx.combo.Users);