[eluser]Majd Taby[/eluser]
hahaha i love the pun...
Here's how it works:
Some plugins "contain" other plugins. For example, the FieldSet plugin contains other plugins inside it. Similarly, the ManyToMany plugin contains other plugins (when you click on Add New). Because each plugin has its own processing requirements and needs to have its hooks/callbacks called, then the containers (fieldset, manytomany) need to know which field is getting processed.
So if you have a fieldset with 4 plugins inside it, it will have prepForDisplay called on it four times, each time with a different $field parameter. On the other hand, standalone plugins don't contain any other plugins, so they don't need a second parameter.
As far as the iterate function returning an array, take a look at lines 102,110,123,128 of codexevents.php
For your problem, I would change the iterate() function like this:
Code:
function iterate ($func_name,$param_array=array()){
$return_array = array();
foreach($this->objects as $name=>$obj){
if(is_array($obj->getIterateNames())){
foreach($obj->getIterateNames() as $field){
$val = (isset($param_array[$field]))? $param_array[$field] : '';
echo get_class($obj)."->$func_name($value,$field);<br>";
$return_array[$field] = $obj->$func_name($val,$field);
}