Jump to content

Get the config inputfield object for a module


MarkE
 Share

Recommended Posts

This is not really a tutorial, but simply a little trick.

I was trying to work on an enhancement for @adrian's module ModuleSettingsImportExport but hit a slight roadblock. For a configurable module I wanted to get the class of an inputfield (set in getModuleConfigInputfields). However I could only see how to get its value, not any way to get the object itself. I did a lot of searching without any resault. Then I realised that you could do it like this:

// $module is the module we are interested in (check it is configurable)
// $fieldName is the name of the config inputfield

$wrap = new InputfieldWrapper();
$module->getModuleConfigInputfields($wrap);
$field = $wrap->get($fieldName);

// $field is the inputfield object for $fieldName

Might be of use to someone (if only me when I come across it again 😉)

  • Like 1
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...