I am maniputing the OG (audience) options on a node/add form. I added the following code to my hook_form_alter(). The changes work. But, when I disable the form element, the value does not appear in the node. But, if #disabled = false, then the value does appear.

//from hook_form_alter()
	// Change the options
	$form['og_nodeapi']['visible']['og_groups']['#options'] = array( $project_node->nid => $project_node->title );

	// Make the option CHECKED
	$form['og_nodeapi']['visible']['og_groups']['#default_value'] = array( $project_node->nid );

	// Disable the form element so users cannot change it
	$form['og_nodeapi']['visible']['og_groups']['#disabled'] = TRUE;

If you then check $node->og_groups in hook_nodeapi() ($op == validate or presave), no group is set. So, drupal lost the value when disabled = true.

Comments

pfrenssen’s picture

Status: Active » Closed (cannot reproduce)

OG is a contributed module but this issue has been filed under Drupal Core. If it were filed under OG it probably had a better chance of getting some answers. Seeing the age of this issue I presume it is better to close this than move it to the OG queue. Feel free to reopen this if this problem is still relevant.