Skip to main content

The additional arguments you pass to drupal_get_form() are available in $form_state['build_info']['args'], but you can't have function calls in your page arguments. I'd suggest the following approach:

function mymodule_menu() {
    $items = array();
    $items['mymodule/example'] = array(
      'page callback' => 'drupal_get_form',
      'page arguments' => array('mymodule_form'),
    );
    return $items;
}


function mymodule_form($form, &$form_state) {
  // this function now uses dev/user friendly named keys
  $vars = mymodule_example_function();
  $form = array();

  $form['heading'] = array(
    '#markup' => check_plain($vars['heading']),
  );

  // use other arguments here 

  return $form;
}

The rest of what you need is in the Form API reference

The additional arguments you pass to drupal_get_form() are available in $form_state['build_info']['args'], but you can't have function calls in your page arguments. I'd suggest the following approach:

function mymodule_menu() {
    $items = array();
    $items['mymodule/example'] = array(
      'page callback' => 'drupal_get_form',
      'page arguments' => array('mymodule_form'),
    );
    return $items;
}


function mymodule_form($form, &$form_state) {
  // this function now uses dev/user friendly named keys
  $vars = mymodule_example_function();
  $form = array();

  $form['heading'] = array(
    '#markup' => check_plain($vars['heading']),
  );

  // use other arguments here
}

The rest of what you need is in the Form API reference

The additional arguments you pass to drupal_get_form() are available in $form_state['build_info']['args'], but you can't have function calls in your page arguments. I'd suggest the following approach:

function mymodule_menu() {
    $items = array();
    $items['mymodule/example'] = array(
      'page callback' => 'drupal_get_form',
      'page arguments' => array('mymodule_form'),
    );
    return $items;
}


function mymodule_form($form, &$form_state) {
  // this function now uses dev/user friendly named keys
  $vars = mymodule_example_function();
  $form = array();

  $form['heading'] = array(
    '#markup' => check_plain($vars['heading']),
  );

  // use other arguments here 

  return $form;
}

The rest of what you need is in the Form API reference

Source Link
skwashd
  • 1k
  • 5
  • 9

The additional arguments you pass to drupal_get_form() are available in $form_state['build_info']['args'], but you can't have function calls in your page arguments. I'd suggest the following approach:

function mymodule_menu() {
    $items = array();
    $items['mymodule/example'] = array(
      'page callback' => 'drupal_get_form',
      'page arguments' => array('mymodule_form'),
    );
    return $items;
}


function mymodule_form($form, &$form_state) {
  // this function now uses dev/user friendly named keys
  $vars = mymodule_example_function();
  $form = array();

  $form['heading'] = array(
    '#markup' => check_plain($vars['heading']),
  );

  // use other arguments here
}

The rest of what you need is in the Form API reference