On this page
Integration with COI
Last updated on
26 February 2018
Integration with COI is simple.
For any form field representing a configuration value, add the full config-object+key to the element. See #config key in example:
$site_config = $this->config('system.site');
$form['site_information']['site_slogan'] = [
'#type' => 'textfield',
'#title' => t('Slogan'),
'#default_value' => $site_config->get('slogan'),
'#description' => t("How this is used depends on your site's theme."),
'#config' => [
'key' => 'system.site:slogan',
],
];
Where the key is the config object, then colon symbol (":"), then config key.
Your module does not need to depend on COI. If COI becomes installed and enabled, your field will automatically receive new functionality.
Secrets
If your field represents a secret, such as passwords, authorization tokens, etc, add the secret key.
$site_config = $this->config('system.site');
$form['site_information']['site_slogan'] = [
'#type' => 'textfield',
'#title' => t('Slogan'),
'#default_value' => $site_config->get('slogan'),
'#description' => t("How this is used depends on your site's theme."),
'#config' => [
'key' => 'system.site:slogan',
'secret' => TRUE,
],
];
The secret key accepts boolean values TRUE or FALSE. If not set, COI assumes FALSE.
Help improve this page
Page status: No known problems
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion