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.
Alternative storage and retrieval mechanism for custom forms.
How does it work?
The most common use-case is to use Hub in a custom form in your
administration UI. You can do this by return hub_closure(). The
hub_closure() function will handle populating default values, as
well as display the data structures in the form element's
#description for priviledged users.
function mymodule_general_settings($form, &$form_state) {
$form['var1'] = array(
'#type' => 'text',
'#title' => t('Var 1'),
);
$form['var2'] = array(
'#type' => 'date',
'#title' => t('Var 2'),
),
$form['set1'] = array(
'#type' => 'fieldset',
'#title' => t('Set 1'),
);
$form['set1']['var3'] = array(
'#type' => 'checkboxes',
'#title' => t('Var 3'),
'#options' => array(
'op1' => t('Option 1'),
'op2' => t('Option 2'),
'op3' => t('Option 3'),
),
),
// .... etc.
// hub_closure() arguments are a unique name for
// your configuration object, and the form array.
return hub_closure(__FUNCTION__, $form);
}
You could also create arbitrary Hub configurations with hub_save().
$config = new stdClass();
$config->name = 'mymodule_security_settings';
$config->data = array(
'security_level' => array(
'anonymous' => 'low',
'authenticated' => 'medium',
'administrator' => 'high',
),
);
hub_save('insert', $config);
Retrieve the data with hub_load().
$config = hub_load('mymodule_security_settings');
By the way, all your configurations are exportable.
Project information
- Unsupported
Not supported (i.e. abandoned), and no longer being developed. Learn more about dealing with unsupported (abandoned) projects - No further development
No longer developed by its maintainers. - Module categories: Developer Tools, Import and Export
- Created by helior on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.