You are here

function onepageprofile_settings in One page profile 7

Same name and namespace in other branches
  1. 6 onepageprofile.module \onepageprofile_settings()

Admin page to change category weights

1 string reference to 'onepageprofile_settings'
onepageprofile_menu in ./onepageprofile.module
Implements hook_menu().

File

./onepageprofile.module, line 91

Code

function onepageprofile_settings() {

  // Build the form
  $form = array();
  $form['onepageprofile_categories'] = array(
    '#tree' => TRUE,
  );

  // Add the categories
  $categories = _onepageprofile_get_categories();
  $tree =& $form['onepageprofile_categories'];
  foreach ($categories as $key => $category) {
    $tree[$key]['title'] = array(
      '#value' => $category['#title'],
    );
    $tree[$key]['weight'] = array(
      '#type' => 'weight',
      '#delta' => max(10, count($categories)),
      '#default_value' => $category['#weight'],
    );
  }

  // Actions
  $form['onepageprofile_submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
    '#submit' => array(
      'onepageprofile_settings_submit',
    ),
  );
  $form['onepageprofile_reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset to defaults'),
    '#submit' => array(
      'onepageprofile_settings_reset',
    ),
  );
  return $form;
}