Hub

Component ID

1092358

Component name

Hub

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

1783

Component created

Component changed

Component body

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.