I've looked around the handbook and searched the forums for a while now, but I can't seem to find anything about the $edit variable. What is the theory behind this variable? To me it appears to be a global variable that can store many different values in an array. So take this example pulled from the OG_Forum module:
$edit = array('name' => $node->title, 'vid' => _forum_get_vid());
$status = taxonomy_save_term($edit);
$containers = variable_get('forum_containers', array());
$containers[] = $edit['tid'];
To me this says an array containing a name and vid are being written to the $edit variable. The taxonomy term is saved and then the value of the forum_containers var is grabbed. But the last line is pulling in a tid value from $edit, but where is this value coming from? Didn't the first call set the $edit var to have two items of name and vid, not tid? Any help to understand this is appreciated.
Josh
Comments
$edit is not global just a common name
$edit is not global just a common name. It is often used in the context of editing something so you may find it used to hold the submitted values. It is also often used in the case where code is performing some action that a user might normally carry out.
In this case the code is creating a new taxonomy term and $edit holds the values needed for creating the new term. In this case the node title is used for the taxonomy term name and vid specifies the vocabulary the term is added to. A side effect of taxonomy_save_term is that it adds the tid of the newly created term to $edit ($edit is passed by reference into taxonomy_save_term).
Thank You
Ah, the pass by reference is what I was missing. It seemed there were a number of people using $edit in their code, that's why I assumed it was a global.
Thanks,
Josh