This came up in the Zulip chat:
@olafgrabienski
I want to mention setting defaults in a module's configuration form. That's what I started to do:
'#description' => t('Additional body class for pages with a Tocbot block.<br />
Default: <code>toc-is-active</code>'),
Instead, I'd like to make use of
'#default_value' => $config->get('tocbot_extrabodyclass')
, for the display of defaults. Is it possible, and could someone post an example? ... ...I'd like to display default settings in the description text of the setting. ...Is there a way to get the value for the description text from (in my case)tocbot/config/tocbot.settings.json
? AFAIK, a changed value would be from the config file in the Backdrop active config directory instead.If there isn't a obvious approach, I'm however fine to hardcode the default values in the description texts. I guess they won't change so often.
@BWPanda
@olafgrabienski The only place default values exist is in your module's
config/*.json
file. Once the module's installed and that file's copied into the active config, it can change. I don't believe there's any (easy) way to read from your module's default config file, so hard-coding is the only way (and I don't think it's the wrong way either - default values are hard-coded in the default config file, so they can be hard-coded in a description text too, just remember to update both places should they ever change).
@olafgrabienski
Thanks for your feedback, @BWPanda! Good to know that hardcoding the values isn't the 'wrong' way in this case. Re "remember to update both places". Actually, there are three places as there is also the install file. And my module has a lot of config values. Unfortunately, all three places are in slightly different format. But as you say: should they ever change ...
@klonos
Seems that we need a
$config->getDefault('what.have.you')
...could be a feature request @olafgrabienski :wink:
Recent comments
I'm glad you've found it quite useful too! I'm curious to know why you'd like to unpublish some of your modules or themes? They're not ready or are they more personal projects? I can help...
My work and a big thanks to all of you
Slight improvement to @argiepiano's procedure. Again for PR 4690, it would be: Using shell access, go to the Backdrop doc root. Run this command to get the diff file...
Workflow for core update with fixes that are not yet in core
This issue is seeing some progress, but there are some questions that might benefit from a UX discussion. https://github.com/backdrop/backdrop-issues/issues/2894
Apr 18th Weekly Meetings