I'm trying to make forms the drupal way, and have been struggling with this one for hours. I'm getting:
Fatal error: Unsupported operand types in /home/www/php/cms/drupal-6.13/includes/form.inc on line 521
That's this line here:

  $form += _element_info('form');
 

Code is here:



$output .= drupal_get_form('group_node_admin_nodes_form');

function group_node_admin_menu() {
  $items['gna'] = array(
    'title' => 'Content',
    'description' => "Assign/unassign individual nodes to individual group members all in one fell swoop.",
    'page callback' => 'drupal_get_form',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
  );
    return $items;
}
//    'type' => MENU_CALLBACK,


function group_node_admin_nodes_form() {

  //$filter = node_build_filter_query();
  $sql = 'SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] .' ORDER BY n.changed DESC';
  $result = pager_query(db_rewrite_sql($sql), 50, 0, NULL, $filter['args']);

  // Enable language column if locale is enabled or if we have any node with language
  $count = db_result(db_query("SELECT COUNT(*) FROM {node} n WHERE language != ''"));
  $multilanguage = (module_exists('locale') || $count);

  $form['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Update options'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $options = array();
  foreach (module_invoke_all('node_operations') as $operation => $array) {
    $options[$operation] = $array['label'];
  }
  $form['options']['operation'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => 'approve',
  );
  $form['options']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
    '#submit' => array('group_node_admin_nodes_submit'),
  );

  $languages = language_list();
  $destination = drupal_get_destination();
  $nodes = array();
  while ($node = db_fetch_object($result)) {
	$form['name'][$node->nid] =  array('#value' => check_plain('turnup')); //check_plain(node_get_types('name', $node))
    $nodes[$node->nid] = '';
    $options = empty($node->language) ? array() : array('language' => $languages[$node->language]);
    $form['title'][$node->nid] = array('#value' => l($node->title, 'node/'. $node->nid, $options));	// .' '. theme('mark', node_mark($node->nid, $node->changed))
    $form['username'][$node->nid] = array('#value' => theme('username', $node));
    $form['status'][$node->nid] =  array('#value' => ($node->status ? t('published') : t('not published')));
    if ($multilanguage) {
      $form['language'][$node->nid] = array('#value' => empty($node->language) ? t('Language neutral') : t($languages[$node->language]->name));
    }
    $form['operations'][$node->nid] = array('#value' => l(t('edit'), 'node/'. $node->nid .'/edit', array('query' => $destination)));
  }
  $form['nodes'] = array('#type' => 'checkboxes', '#options' => $nodes);
  $form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
//  $form['#theme'] = 'group_node_admin_nodes';
  return $form;
}


function group_node_admin_nodes_validate($form, &$form_state) {
  $nodes = array_filter($form_state['values']['nodes']);
  if (count($nodes) == 0) {
    form_set_error('', t('No items selected.'));
  }
}


function group_node_admin_nodes_submit($form, &$form_state) {
//do nothing
}

return($output);

Comments

work77’s picture

so I got rid of the drupal_get_form function call and set the callback page to 'group_node_admin_nodes_form', re-enabled my module and am no longer getting the error. But instead of the form displaying on the page, it's just showing an empty array. I print_r()'d the $form and it looks fine - full of the form elements. So, what do I need to do to display the form?