The following module works, but changing 'get' with 'post' and $_GET with $_POST not
(PHP Version 4.3.11)


function example_form($example = '') {
  $form['fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Example module'));
  $form['fieldset']['item'] = array(
    '#type' => 'item',
    '#title' => '',
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $form['fieldset']['item']['example'] = array(
    '#type' => 'textfield',
    '#title' => t('example'),
    '#default_value' => $example,
    '#size' => 20,
    '#maxlength' => 1024
  );
  $form['fieldset']['item']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Verify')
  );
      
  $form['#method'] = 'get';
  $form['#action'] = url('example');
  
  return drupal_get_form('example_form', $form);
}

function _example_all() {
  $example = isset($_GET['edit']['example'])? trim($_GET['edit']['example']): '';
  
  $output = example_form($example) . '<br /> example:' .  $example;

  return $output;
}

function example_help($section = '') {
  $output = '';

  switch ($section) {
    case 'admin/modules#description':
      $output = t('Example module.');
    break;
  }
  
  return $output;
}

function example_perm() {
  return array('execute example module');
}

function example_menu($may_cache) {
  $items = array();
  
  if($may_cache)
  {
    $items[] = array('path' => 'example',
      'title' => t('example module'),
      'callback' => '_example_all',
      'access' => user_access('execute example module'));
  }

  return $items;
}

Comments

moshe weitzman’s picture

Priority: Critical » Normal
Status: Active » Closed (works as designed)

the form api is designed so you do not need to reference those superglobals. what are you tring to do. plese reopen with more detail.

he_who_shall_not_be_named’s picture

Thanks a lot. The following example is a bit unusual but it works.
Thank you again.


function example_form($example = '') {
  $form['fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Example module'));
  $form['fieldset']['item'] = array(
    '#type' => 'item',
    '#title' => '',
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $form['fieldset']['item']['example'] = array(
    '#type' => 'textfield',
    '#title' => t('example'),
    '#default_value' => $example,
    '#size' => 20,
    '#maxlength' => 1024
  );
  $form['fieldset']['item']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Verify')
  );
      
  $form['#method'] = 'post';
  $form['#action'] = url('example');
  
  return drupal_get_form('example_form', $form);
}

function example_form_submit($form_id, $edit) {
  $_SESSION['example'] = $edit['example'];
  
  return url('example');
}

function _example_all() {
  $example = isset($_SESSION['example'])? trim($_SESSION['example']): '';
  
  $output = example_form($example) . '<br /> example:' .  $example;

  return $output;
}

function example_help($section = '') {
  $output = '';

  switch ($section) {
    case 'admin/modules#description':
      $output = t('Example module.');
    break;
  }
  
  return $output;
}

function example_perm() {
  return array('execute example module');
}

function example_menu($may_cache) {
  $items = array();
  
  if($may_cache)
  {
    $items[] = array('path' => 'example',
      'title' => t('example module'),
      'callback' => '_example_all',
      'access' => user_access('execute example module'));
  }

  return $items;
}