gornycreative Posted November 17, 2022 Share Posted November 17, 2022 Hi, I'm trying to wrap my head around configurable modules. The issue I am running into is that I'm not sure when or how to get the configured values to be used for other backend processes. At first, the config saved but nothing on the backend in terms of methods was using those value. Now when values change, the backend methods pick up the changed values to the config and uses those in my method calls, but if a value didn't change it doesn't get brought in to my public vars. The structure I have in place (roughly) is:\ class ClassName extends WireData implements Module, ConfigurableModule { getModuleInfo() { } public var declarations public function ready() { $mod_config = modules()->getConfig('ClassName') //I have code here that assigns values from the $mod_config array to my public vars if values exist } public function getModuleConfigImputfields() { //Here I've got my fields set up properly and the config saves fine and values load fine from the DB. } } Is there something else I need to do to utilize those values? Link to comment Share on other sites More sharing options...
bernhard Posted November 18, 2022 Share Posted November 18, 2022 Config variables should be available as properties of the module if I'm not missing anything. So if you add a config inputfield with the name 'foo' it should be available as $this->foo. Or from outside the module it should be available as $modules->get('YourModule')->foo; 2 1 Link to comment Share on other sites More sharing options...
gebeer Posted November 18, 2022 Share Posted November 18, 2022 5 hours ago, gornycreative said: getModuleConfigImputfields just to make sure, did you copy/paste this from your code? There is a typo "Imput", note the "m". It should read "getModuleConfigInputfields" To retrieve module config data from anywhere you can also use https://processwire.com/api/ref/modules/get-config/ 3 Link to comment Share on other sites More sharing options...
gornycreative Posted November 18, 2022 Author Share Posted November 18, 2022 No that was just really quick pseudo. I just wanted to make sure I wasn't putting things in the wrong place generally. I was able to get the information reliably. Link to comment Share on other sites More sharing options...
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