You are here

function _key_element_expand in Key 7.2

Same name and namespace in other branches
  1. 7 key.module \_key_element_expand()

Process function to expand the key element.

1 string reference to '_key_element_expand'
key_element_info in ./key.module
Implements hook_element_info().

File

./key.module, line 181
Provides the ability to manage keys, which can be used by other modules.

Code

function _key_element_expand($element) {
  $element['#empty_option'] = t('Select a key');
  $element['#options'] = key_get_configs_as_options();
  if (!empty($element['#filters'])) {
    $element['#options'] = _key_configs_filter($element['#options'], $element['#filters']);
  }

  // Prefix the default description with a information about keys.
  if ($element['#key_description']) {
    $original_description = isset($element['#description']) ? $element['#description'] : '';
    $key_description = t('Choose an available key to use.');
    $key_description .= ' ' . t('If your key is not listed, <a href="@url">create a new key</a>.', array(
      '@url' => '/' . KEY_MENU_PATH,
    ));
    $element['#description'] = $key_description . ' ' . $original_description;
  }
  return $element;
}