sam13579 Posted June 1, 2022 Posted June 1, 2022 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? 1
Robin S Posted June 2, 2022 Posted June 2, 2022 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. 4
bernhard Posted June 2, 2022 Posted June 2, 2022 Using my vscode snippets extension all you need to do is adding your settings to the getModuleConfigInputfields method: $inputfields->add([ 'type' => 'text', 'label' => 'Foo Setting', 'name' => 'foo', 'value' => $this->foo, ]); return $inputfields; https://marketplace.visualstudio.com/items?itemName=baumrock.pwsnippets 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now