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

    I created a mod-combo select in the manager but when I try to save my form it saves the name instead of the ID. How can I change this?

    Best regards,

    Rogier
      • 25586
      • 105 Posts
      Right now in the create.php I check my table for the name and return the ID but I think I can be easier.

      I also wondered how I can add a refresh button the my mod-combo, does anyone knows?

      Thanks! I would be great is you guys can help me out!
        • 33976 ☆ A M B ☆
        • 571 Posts
        Hi rover87,

        You might want to check displayField & valueField parameters.

        If that may help you, here is an example of how i extend MODx.combo.ComboBox

        adxPremium.combo.premiumOffers = function(config) {
            config = config || {};
        
            Ext.applyIf(config, {
                name : 'offerlist'
                ,hiddenName : 'offerlist'
                ,pageSize: 10                    // 10 results in the combo store, after the user needs to use the pagination
                ,displayField : 'name'          // the field name displayed to the user
                ,valueField : 'id'                  // the field name to grab the value from, this is the value submitted
                ,fields: ['id', 'name']             // all the fields used in the combo (displayed or not)
                ,triggerAction : 'all'
                ,lazyRender: true
                ,allowBlank: false
                ,url: adxPremium.config.connector_url
                ,listWidth: 0                       // disabled in order to get the list width equal to the field width
                ,baseParams: {
                    action: 'mgr/offer/getlist'  // the processor triggered to fill the combo box store
                    ,combo: true
                }
            });
            adxPremium.combo.premiumOffers.superclass.constructor.call(this, config);
        };
        Ext.extend(adxPremium.combo.premiumOffers, MODx.combo.ComboBox);
        Ext.reg('adxpremium-combo-offerlist', adxPremium.combo.premiumOffers);
        


        Extending MODx.combo.ComboBox that way displays a "refresh" in my list (as well as a pagination).

        Hope that will help you (if not, do not hesitate to paste your code here).
          • 25586
          • 105 Posts
          Thanks romain! I got it working and everything is working fine at the moment! hiddenName : 'artist' did the trick smiley