Skip to main content

Example code for creating an admin page for Drupal 7 module

Updated by Tim Rabbetts on
abstract, geometric, world
function pivotal_menu() {

  $items = array();
  $items['admin/config/development/pivotal'] = array(
    'title' => 'Pivotal settings',
    'description' => 'Pivotal access keys and config settings',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('pivotal_admin'),
    'access arguments' => array('administer admin menu'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

function pivotal_admin() {
  $form = array();
  $form['piv_api_token'] = array(
    '#type' => 'textfield',
    '#title' => t('Pivotal api token'),
    '#description' => t("You can get this from pivotals profile section."),
    '#required' => TRUE,
    '#default_value' => variable_get('piv_api_token', ''),
  );
  $form['piv_project'] = array(
    '#type' => 'textfield',
    '#title' => t('Pivotal project id'),
    '#description' => t("You can get this from url when you are view a projects, its the number at end of url."),
    '#required' => TRUE,
    '#default_value' => variable_get('piv_project', ''),
  );
  return system_settings_form($form);
}

 

Add new comment