Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
To make it easy for modules to integrate with Key, the version of the module for Drupal 7 adds a new form API element called key. It extends the select element, but fills #options with the list of available keys. It also provides additional instructions for using and defining keys in the #description. Here's an example of what that looks like in code:
$form['secret_key'] = array(
'#type' => 'key',
'#title' => t('Secret key'),
);
Comment | File | Size | Author |
---|---|---|---|
#5 | create_new_key_form_api-2624690-5.patch | 2.47 KB | tynor |
#3 | create_new_key_form_api-2624690-3.patch | 2.47 KB | rlhawk |
Comments
Comment #2
rlhawkIt probably makes sense to call this "key_select", just to be specific and because later on we may want to add other form elements, such as one that displays available keys as radios, or as a text field with autocomplete.
Comment #3
rlhawkHere's a patch that adds a basic version of the key_select element. It extends the select form element, but uses the keys as options. It also allows the element to include information about keys to the description. The #filters property is defined, but has no effect yet.
Comment #4
rlhawkComment #5
tynor CreditAttribution: tynor commentedNew patch that uses the key.repository service name instead of the old key_repository.
Comment #6
rlhawkLooks good.
Comment #8
rlhawk