title: CakePHP mathematic-calculation field?
body: <p>(Database structure like <a href="https://stackoverflow.com/questions/1545764/cakephp-select-default-value-in-select-input">CakePHP select default value in SELECT input</a>)</p>
  
  <p>So, I have two tables in CakePHP: Trees, and Leafs.  Every Leaf has a <code>tree_id</code> for its corresponding tree.  Every leaf also has a numeric <code>value</code>.  The default view that I baked for trees just lists all the trees in a table.  Is there a way to add a dynamic column to that view's table that SUMS all the leafs of that tree and displays the sum in the table, as well as another field showing the number of leafs a tree has?</p>
  
  <p>example:</p>
  
  <p><code>Leafs</code></p>
  
  <pre><code>Id   |  Tree Id  |  Leaf value
  -----+-----------+---------------
  24   |  1        | 19
  70   |  1        | 33
  121  |  1        | 30
  </code></pre>
  
  <p><code>Trees</code></p>
  
  <pre><code>Id   |  Tree  |  Number of leafs  |  Sum of leafs  |  Actions
  -----+--------+-------------------+----------------+-------------------
  1    |  foo   |  120              |  7270          |  View Edit Delete
  2    |  bar   |  72               |  4028          |  View Edit Delete
  </code></pre>