when going to a page like "node/add/forum/89" My secondary select box of taxonomy was getting deleted. I found that when I changed this one line of code it fixed it.

So I am subbmitting this as a bug fix. I am not sure if I removed some functionality, but my site appears to be working now with this patch applied

function og_forum_form_alter($form_id, &$form) {
  // Auto-select group's forum when adding/editing a forum topic
  if ($form_id == 'forum_node_form') {
    $gid = db_result(db_query("SELECT nid FROM {og_term} WHERE tid = %d", arg(3)));
    if (!empty($gid)) {
      $group = node_load($gid);
      og_set_group_context($group);
      $vid = _forum_get_vid();
      $old_form = $form['taxonomy'][$vid];
-      foreach ($form['taxonomy'] as $key => $value) {
+      foreach ($form['taxonomy'][$vid] as $key => $value) {
        if (substr($key, 0, 1) != '#') {
 -         unset($form['taxonomy'][$key]);
 +        unset($form['taxonomy'][$vid][$key]);
        }
      }
      $form['taxonomy'][$vid] = $old_form;
      if (user_access('administer organic groups') || variable_get('og_audience_checkboxes', TRUE)) {
        $form['og_nodeapi']['visible']['og_groups']['#default_value'][] = $gid;
      }
      else {
        $form['og_nodeapi']['invisible']['og_groups']['#default_value'][] = $gid;
      }
      $form['og_nodeapi']['#collapsed'] = $gid ? TRUE : FALSE;
    }
  }
}

Comments

markDrupal’s picture

Status: Needs review » Closed (fixed)

I found a whole different chunk of code that worked better.

function og_forum_form_alter($form_id, &$form) {
  // Auto-select group's forum when adding/editing a forum topic
  if ($form_id == 'forum_node_form') {
    $group = og_get_group_context();
    if ($group->nid) {
      $vid =  _forum_get_vid();
      $term = arg(3);
      $form['taxonomy'][$vid]['#default_value'] = array($term);
      if (!user_access('administer forums')) {
        unset($form['taxonomy'][$vid]['#default_value']);
        //unset ($form['taxonomy'][$vid]['#type']);
        $form['taxonomy']['#type'] = 'fieldset';
        $form['taxonomy']['#title'] = 'Forum context';//comment this line out to hide the drop down; i couldn't get [#type] = 'hidden' to work
        $form['taxonomy']['#collapsible'] = TRUE;
        $form['taxonomy']['#collapsed'] = TRUE;
        $form['taxonomy'][$vid]['#value'] = $term;
        $form['taxonomy'][$vid]['#description'] = 'When inside a group forum, changing this value has no effect.';
      }
    }
  }
}