(Database structure like http://stackoverflow.com/questions/1545764/cakephp-select-default-value-in-select-input)

So, I've two tables in CakePHP: Trees, and Leafs. Every Leaf includes a tree_id because of its corresponding tree. Every leaf also offers a number value. The default view which i baked for trees just lists all of the trees inside a table. It is possible to method to give a dynamic column to that particular view's table that SUMS all of the leafs of this tree and shows the sum within the table, in addition to another area showing the amount of leafs a tree has?

example:

Leafs

Id   |  Tree Id  |  Leaf value
-----+-----------+---------------
24   |  1        | 19
70   |  1        | 33
121  |  1        | 30

Trees

Id   |  Tree  |  Number of leafs  |  Sum of leafs  |  Actions
-----+--------+-------------------+----------------+-------------------
1    |  foo   |  120              |  7270          |  View Edit Delete
2    |  bar   |  72               |  4028          |  View Edit Delete

Two ideas:

Fetch the summed area dynamically every time you require it while using Containable behavior, like (off the top my mind):

$this->Tree->find('all', array(
    ...
    'contain' => array(
        'Leaf' => array(
            'fields' => array('SUM(Leaf.value)'),
            'group'  => array('Leaf.tree_id')
        )
    )
);

Or produce a new column within the Tree model like leaf_values increase it any time you change something within the Leaf model:

// Leaf model
function afterSave() {
    $sum = /* calculate sum */;
    $this->Tree->updateAll(
        array('Tree.leaf_values' => $sum),
        array('Tree.id' => $this->data['Leaf']['tree_id'])
    );
}

function afterDelete() {
    // same for afterDelete
}

I do not think you should use group within containable calls.