I noticed this when trying to drag'n'drop elements in the "Manage fields" screen in CCK for a content type enabled to post to a group. When that happens, CCK uses $form['og_nodeapi'] for the extra element that can be managed from this screen. But there was no row, and I got a javascript error.

Said error is caused by og_read_only_form_alter() that wants to alter all forms, where it should only focus on node edit forms. The piece of code that removes $form['og_nodeapi'] from the CCK form is this:

  if ( (count($form['og_nodeapi']['visible']['og_groups']['#options']) == 0) && 
  (count($form['og_nodeapi']['invisible']['og_groups']['#value']) == 0)) {
    unset($form['og_nodeapi']);
  }

I think this could be fixed as follows. Apply the following to og_read_only_form_alter():

 function og_read_only_form_alter(&$form, &$form_state, $form_id)
 {
+  // Ignore this form if this is not a node edit form.
+  if (!isset($form['#node']) || $form_id != $form['#node']->type .'_node_form') {
+    return;
+  }
+
   $inaccessible_groups = array();
   $node = $form['#node'];

Comments

yrocq’s picture

Assigned: Unassigned » yrocq
Status: Needs review » Fixed

Committed in DRUPAL-6--1 and DRUPAL-6--2. Thanks !

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.