• Reset your password
Home
OO PHP, Drupal, Symfony Developer and Architect
Tim Rabbetts

Main navigation

  • Home
  • Blog
  • Log in

Example code for creating an admin page for Drupal 7 module

Breadcrumb

  • Home
  • blog
  • example code for creating an admin page for drupal 7 module
  • Example code for creating an admin page for Drupal 7 module
Tim
Rabbetts
By zarexogre | 1:17 PM UTC, Thu April 02, 2020
abstract, geometric, world
drupal
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);
}