TransWikia.com

Updating plugin/module config via template/controller

Craft CMS Asked by Cole Henley on December 9, 2020

I have a plugin/module that synchronises local records with a Google Sheet managed by the client.
The URL for this doc is stored in a module config.

I want the client to be able to update this via the control panel so have created a template for editing and a controller to update the config. This is all fine locally but in the client environment where allowAdminChanges is set to false this won’t save and I get the following error:

 Changes to the project config are not possible while in read-only mode.

I have tried both Craft::$app->projectConfig->set('my-module', $settings); and Craft::$app->getSystemSettings()->saveSettings('mud-module', $settings) with same ersponse.

Is there a way to update config when allowAdminChanges is set to 0/false?

One Answer

In short, no. If this is config or data which are environment specific, they are as likely not good candidates for project config. Perhaps consider moving them to a table and access them through a Record/Model?

Correct answer by Andy on December 9, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP