Jump to content

[SOLVED] Access inputfield config data


jploch
 Share

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() {
        parent::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
$fieldsetGrid->append($f);

$inputfields->append($fieldsetGrid);

 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');
$default->gridMaxWidth;

Any Ideas?

Link to comment
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');
$default->gridMaxWidth;

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

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

It all makes sense ?

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...