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

    How to make a save button on the right top of the CMP
    on form page?
    (with the same of Camper Management CMP)
    http://rtfm.modx.com/display/ADDON/CamperManagement

    Thank you very much
      Web developer at Socket9. Bangkok, Thailand.
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Use the "buttons" config option in your Page class, and define what you want to do in the "handler" function.

      This is the related CamperManagement source code: https://github.com/Mark-H/CamperManagement/blob/master/assets/components/campermanagement/js/mgr/page.newcamper.js#L58
        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.
        • 42544
        • 7 Posts
        Thanks for that reference, but I still do not understand...

        Here's some more details from my project: I'm working on a custom CMP page to edit a custom database table, the first page with the grid loads the data, I have created a "Create New" button for a new entry, which loads a new page with the empty fields for the entry.

        But my problem is I can't figure out how to add a "Save" button, and make it save the data to the custom database table.

        I have looked at the Doodles example plugin and found this code, in this .js file: /asset/components/<CMP name>/js/mgr/*.js

        Doodles.window.CreateDoodle = function(config) {
            config = config || {};
            Ext.applyIf(config,{
                title: _('doodles.doodle_create')
                ,url: Doodles.config.connectorUrl
                ,baseParams: {
                    action: 'mgr/doodle/create'
                }
                ,fields: [{
                    xtype: 'textfield'
                    ,fieldLabel: _('doodles.name')
                    ,name: 'reviewer'
                    ,width: 300
                }
            ]
            });
            Doodles.window.CreateDoodle.superclass.constructor.call(this,config);
        };
        


        but the "Save" button not appear, there's no error feedback from the code or in the Error Log?

        Does anyone know how to solve this?
          Web developer at Socket9. Bangkok, Thailand.
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          Make sure you also have these lines for the window:
          Ext.extend(Doodles.window.CreateDoodle,MODx.Window);
          Ext.reg('doodles-window-doodle-create',Doodles.window.CreateDoodle);


          The first one tells it to inherit everything that's defined in MODx.Window (which includes your save button), and the second one makes the window available via
          xtype: 'doodles-window-doodle-create'
            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.