I'm trying to create a page with multiple forms on one page - one form for each project in the project_projects table. What I'm trying to do is call drupal_get_form() multiple times and pass the form function two parameters. First, here is the code:

/*
 * Adds the capability to assign access to projects
 * to specific users
 */

/*
 * Implementation of hook_menu()
 */
function project_permissions_menu($may_cache) {
  $items = array();
    if ($may_cache) {
      $items[] = array(
        'path' => 'admin/project/project_permissions',
        'title' => t('Project Permissions'),
        'description' => t('Set access to projects'),
        'access' => user_access('administer projects'),
        'callback' => 'project_permissions_page',        
        'type' => MENU_NORMAL_ITEM
      );
    }
    return $items;
}

function project_permissions_page() {
  $output = t('Use this page to assign permissions to each project'); 

  //get list of projects
  $sql = "SELECT nid, uri FROM {project_projects}";
  $result = db_query($sql);
  
  //for each project, create a fieldset with project and user fields
  while ($projects = mysql_fetch_object($result)) {
    $project_name = $projects->uri;
    $project_nid = $projects->nid;

    //call form function
    $output .= drupal_get_form(project_permissions_admin_settings,$project_name,$project_nid);     
  }
  return $output;  
}

/*
 * Define the project permissions settings form
 */
function project_permissions_admin_settings($project_name, $project_nid) {     
  //set dynamic form id
  $form['#id'] = 'project_permissions_admin_settings_'.$project_nid;
  
  $form[$project_nid] = array(
    '#type' => 'fieldset',
    '#title' => $project_name,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );  

  $form[$project_nid]['projects'] = array(
    '#type' => 'textfield',
    '#title' => t('Project name'),
    '#maxlength' => 30,
    '#size' => 30,
    '#default_value' => $project_name,   
  );
  
  $form[$project_nid]['users'] = array(
    '#type' => 'select',
    '#title' => t('Users with access to project'),
    '#description' => t('Select users to be asssigned to the project'),    
    '#options' => _get_user_list(),
    '#multiple' => TRUE
  );
  
  $form[$project_nid]['nid'] = array(
    '#type' => 'hidden',
    '#value'=> $project_nid,
  );
  
  $form[$project_nid]['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit'
  );    
  return $form;
}  

/*
 * Gets lists of projects from project_projects table
 */
function _get_projects_list() {
  $sql = "SELECT nid, uri FROM {project_projects}";
  $result = db_query($sql) or die('Error'. mysql_error());
  while($projects = db_fetch_object($result)) {
    $options[$projects->nid] = $projects->uri;
  }
  return $options;
}

/*
 * Gets lists of users from users table
 */
function _get_user_list() {
  $sql = "SELECT uid, name FROM {users} WHERE uid > %d";
  $result = db_query($sql,0) or die('Error'. mysql_error());
  while($users = db_fetch_object($result)) {
    $options[$users->uid] = $users->name;
  }
  return $options;
}  

The problem is, when I bring up the page, the following things happen:

  1. I get an error that says "warning: Missing argument 1 for project_permissions_admin_settings() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\designevolve\sites\all\modules\project_permissions\project_permissions.module on line 48." I also get it for argument 2. Line 48 is "function project_permissions_admin_settings($project_name, $project_nid) {"
  2. I get the two fields, but they are not in a collapsible fieldset, and other data isn't there, which shows that the parameters aren't being passed.

I've tried other variations on the drupal_get_form call, but with no luck.

Is the problem that I'm calling the same form function multiple times? If so, is there a way around it?

Thanks.