You are here

function units_admin_settings in Units of Measurement 6

Units configuration form

1 string reference to 'units_admin_settings'
units_menu in ./units.module
Implementation of hook_menu()

File

./units.admin.inc, line 11
Units admin UI.

Code

function units_admin_settings() {
  $form = array();
  $description = t('Configure site-wide list of enabled units. Modules that integrate with Units module may use this list.
  <br/>If nothing is selected in ALL categories, all units will be enabled.');
  $form['description'] = array(
    '#value' => $description,
  );
  $units = units_get_units();
  $categories = array();
  foreach ($units as $id => $unit) {
    $categories[$unit['category_id']] = $unit['category'];
  }
  foreach ($categories as $cat_id => $desc) {
    $form['category_' . $cat_id] = array(
      '#type' => 'fieldset',
      '#title' => $desc,
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    foreach ($units as $id => $unit) {
      if ($unit['category_id'] == $cat_id) {
        $form['category_' . $cat_id]['enable_' . $id] = array(
          '#type' => 'checkbox',
          '#title' => $unit['fullname'],
          '#default_value' => in_array($id, units_get_enabled_units()) ? 1 : 0,
        );
      }
    }
  }
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#submit' => array(
      'units_admin_settings_submit',
    ),
  );
  return $form;
}