I have created a module the generates a form, validates submissions, saves the data in a table that the module creates on install and then integrates with a 3rd party system. This all works great but I would now like to add some settings to the module but there is no settings column for modules. So what would be the best way to add settings for the module that can changed in the control panel?
1 Answer
For modules, you just go ahead and create your own DB table that stores your module settings. So just like you create your modules main table for storing data submitted from your form when you install it, also create a table for your modules settings (something like exp_my_module_name_settings
).
Follow the documentation for creating Control Panel pages for your module, and just create a form page that submits to itself (and have the method in the back-end update your settings table on POST).
Yes, extensions have settings built into the the exp_extensions
table, but they are meant to be simpler and just inject new logic via hooks. Modules are considered a whole new addition to your CMS, so think of a module more like a complete software package. You handle your module settings in its own table.