Jump to content

module config data not present in console


bernhard
 Share

Recommended Posts

hey @adrian hope you are fine ? 

today I noticed a very strange issue with this little and simple module:

Spoiler
<?php namespace ProcessWire;
class Demo extends WireData implements Module, ConfigurableModule {

  public static function getModuleInfo() {
    return [
      'title' => 'Demo',
      'version' => '0.0.1',
      'summary' => 'Demo.at API',
      'autoload' => false,
      'singular' => true,
      'icon' => 'code',
      'requires' => [],
      'installs' => [],
    ];
  }

  public function init() {
  }

  /**
  * Config inputfields
  * @param InputfieldWrapper $inputfields
  */
  public function getModuleConfigInputfields($inputfields) {

    $inputfields->add([
      'type' => 'URL',
      'name' => 'url',
      'label' => 'Endpoint URL',
      'value' => $this->url,
      'required' => true,
    ]);

    return $inputfields;
  }
}

 

When I do this:

$m = $modules->get('Demo');
db($m);
db($m->url);

...in the Tracy Console it does NOT show any data when I'm in the module's config screen. When I'm on any other page it shows data as it should. Note that the issue does only occur on a non-autoload module. Making the module autoload fixes the issue (that might help for debugging).

Any ideas why this could happen?

---

On module's config page:

JlerDMU.png

On any other page:

FygGP7x.png

 

  • Like 2
Link to comment
Share on other sites

Nice catch @bernhard - should be fixed in the latest version.

FYI in case you don't already know - if you are on the module settings page, the RequestInfo panel will show all the module settings.

Also, you can just do:

d($module);

when on a module settings page because $module is set to the current module, same as $field and $template when on the settings for any field or template.

  • Like 1
Link to comment
Share on other sites

18 hours ago, adrian said:

Nice catch @bernhard - should be fixed in the latest version.

Jep, thx ?

18 hours ago, adrian said:

FYI in case you don't already know - if you are on the module settings page, the RequestInfo panel will show all the module settings.

Also, you can just do:

d($module);

when on a module settings page because $module is set to the current module, same as $field and $template when on the settings for any field or template.

Yeah, I'm using that often, thx. Just needed to test a little new module that handles API requests and I was totally confused that things where all NULL in my console code whereas values where obviously saved in the config (as fields where filled). Thx for the fix!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...