Jump to content

[SOLVED] Access inputfield config data

Recommended Posts

Hey folks,

Iam working on a module that extends InputfieldPageTable. I use PageTableExtended as a starting point and all went well so far, except I can't access my config values outside of the module file. The config values allways return the defaults, and not the values in the pw field settings. 

Here is the code that sets the defaults inside my inputfield module file:

 public function init() {
      // defaults
        $this->set('gridMaxWidth', '1600');
        $this->set('gridColumns', '12');

Here is how I add the config field:

public function ___getConfigInputfields() {

$inputfields = parent::___getConfigInputfields();

$fieldsetGrid = $this->modules->get('InputfieldFieldset');
$fieldsetGrid->label = $this->_('Default Grid Settings');  
$f = $this->wire('modules')->get('InputfieldText');
$f->attr('name', 'gridMaxWidth');
$f->attr('value', $this->gridMaxWidth);
$f->label = $this->_('Container max width');
$f->description = $this->_('Grid container max width in px'); // page name format description
$f->notes = $this->_('default is 1600'); // page name format notes


 return $inputfields;

Accessing the values outside my module files like this (this gives me the default: 1600, even if I insert another value in the backend field settings):

$default = $this->wire('modules')->get('InputfieldPageGrid');

Any Ideas?

Link to post
Share on other sites

ok I think a understand now.
This is giving me the data from the field settings page in pw:

$default = $this->wire("fields")->get('fieldname');

While this is just giving me the defaults from the inputfield module:

$default = $this->wire('modules')->get('InputfieldPageGrid');

It all makes sense 🙂

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Neue Rituale
      or in the modules directory: https://processwire.com/modules/fieldtype-oembed/
    • By carlitoselmago
      It's been twice this year as a PW developer where clients have asqued me to have a way to put content on specific coordinates of a picture. Something like what image maps are made of. But not necesarly on links, sometimes text, sometimes images and links. 
      So I've been thinking to build an inputfield for that purpose. But I'm not sure how could it be the most flexible so I can share it in github/modules page.
      Ideally it would need to work like a repeater field where you start uploading an image and then adding any custom field like title, url etc. So the user could add multiple elements floating over that image.
      Does anybody here know the ideal way to start the arquitecture of something like that? I could just hardcode the fields I need for the website I have to code this month but it would be nice to be something more flexible.
    • By Robin S
      If your module has a lot of config fields you might want to divide them into groups inside a tabbed interface. Here is a demonstration module showing how this can be done.

      Thanks to @kixe for providing my starting point in this forum topic.
    • By theoretic
      Hi there! And thanks for Processwire!
      It appears there's a possible bug in Processwire 3.0.170 concerning file and/or image inputfield. Creating such a field results in the following error:

      Fatal Error: Uncaught Error: Call to a member function get() on null
      The inputfield is created however. The closer look reveals a problem at line 60 in wire\modules\Fieldtype\FieldtypeFile\config.php:
      if(!$value) $value = $fieldtype->get('defaultFileExtensions'); Commenting this line removes the problem, but the newly created inputfield requires 'Allowed file extensions' config option to be set (which is rather expectable since i commented the above-cited line of code). Never faced this problem before, hope it can be resolved.
    • By Lewis Newson
      Hi All,
      Im working on streamlining my email sending setup for SMTP. I have a page where the user of the website can input the SMTP host, port, connection type email and password etc but the password field has an additional box underneath it for 'Confirming' it as if it were a new password. The placeholder text also says 'New Password' but I want to be able to change that. I just need an input field where they can enter their SMTP password without it being plain text.
      Thanks for your help!
  • Create New...