Hide
on 2/9/06

A long time ago, I took to using elements as shown in the paste below.

  1. <?php
  2. echo $this->renderElement("Element",$params);
  3. ?>

At the time, this was the only way I could find to pass the information from the view in general to the element. If this was needed at all, it was probably a temporary glitch but I kept to this syntax since that time. It is overkill to do this now, and moreover if you use the above you may get sporadic errors like "Warning: array_merge_recursive(): recursion detected in /cake/libs/view/view.php on line 406".

The way to avoid such problems is to not do what isn't necessary ;)

  1. <?php
  2. // If the view already contains everything of
  3. interest to the Element there is no need to pass any params
  4. echo $this->renderElement("Element");
  5. // If there is some need
  6. to pass extra parameters, pass just the parameters of interest
  7. echo
  8. $this->renderElement("Element",array("extra"=>$parameter));
  9. ?>

I hope the time I spent trying to figure this out is saved for others :)

0 Responses to Elements and Recursion