gornycreative Posted June 30, 2023 Share Posted June 30, 2023 What is the best way to get an array of the default settings for a given fieldtype, and are these defined at the core module layer or a class layer or somewhere else? This seems to be where I should go but I've had problems figuring out exactly how to call it abstractly: https://processwire.com/api/ref/fieldtype/get-config-array/ I'm not talking about the configuration for a fieldtype instance, I mean the config of the class. Link to comment Share on other sites More sharing options...
bernhard Posted June 30, 2023 Share Posted June 30, 2023 That would be good to know for RockMigrations so we could highlight all non-default values in the export code section ? 2 Link to comment Share on other sites More sharing options...
poljpocket Posted July 11, 2023 Share Posted July 11, 2023 I am not sure I get your question exactly right, but nonetheless: A given Fieldtype is in itself just a fancy form of a ProcessWire Module and thus, I assume you are talking about the defaults of the form rendered on the Modules > Configure > NameOfYourFieldtype screen, correct? To get a list of any Module's configuration, you can use: wire("modules")->getConfig("YourFieldtypeName") as found in the docs here. Ultimatively, this calls Modules::getConfig() or as of 3.0.219, ModulesConfigs::getConfig() which just reads whatever the database has stored for given WireData (a parent class of Module). This will at least give you the Module's current config (possibly amongst others AND as possibly modified by the user). I know this isn't the solution because there isn't any given default way to set values for a Module. It is really up to the Module's author. Also, not every Module must have a config. I am afraid, there might be no general solution at all. Link to comment Share on other sites More sharing options...
gornycreative Posted July 17, 2023 Author Share Posted July 17, 2023 On 6/30/2023 at 4:17 PM, bernhard said: That would be good to know for RockMigrations so we could highlight all non-default values in the export code section ? Exactly why I asked. And there is a potential solution actually and I found it and started working on some things and forgot to come back to this. The getTableData() function for fields seems to pull just the configured settings in the database table. getExportData actually uses the data from the getTableData call and merges it. It's in wire/core/Field.php 1 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