Advertising sustains the DA. Ads are hidden for members. Join today

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: