Jump to content

How to add options while developing a processwire module?


Recommended Posts

I am a noob at this framework. While looking for dynamic options I found many modules have options/settings in the module. While I wanted to develop a module I found that I lack the knowledge of adding options in a module setting page. How to add options (radio buttons,selectors) in my processwire module?

  • Like 1
Link to comment
Share on other sites

You can learn from studying the Helloworld module: https://processwire.com/modules/helloworld/

From the readme:

Quote

If you DO want your module to be configurable, do ONE of the following:

  • Option A: Use a getModuleConfigInputfields() method in the module:
    Edit the getModuleConfigInputfields() method at the bottom of the .module file and update as needed for your configuration. Update the __construct() method to set your default configuration values. Update the phpdoc comments at the top of the .module file to provide documentation for your configurable settings.

  • Option B: Use an external ModuleName.config.php file:
    Copy the extras/Helloworld.config.php file to ModuleName.config.php (placing it in the same directory as your module) and update the file as needed. Remove the getModuleConfigInputfields() method from the .module file. You may also remove the setting of default configuration values from the __construct() method, as ProcessWire will handle this for you when using an external configuration file. Optionally add phpdoc comments at the top of the .module file to provide documentation for your configurable settings.

 

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...