Home

Tue, May. 6th, 2008, 11:20 pm
Set::merge, Set::extract and further goodies

So, I found a couple of cool demos of the Set class (and this time I understand more of them).
The best place to look at how the Set class works is in the 'set.test.php' test case. It's a bit more obvious than reading the source.
In any case, check out this site for some nice demos: http://debuggable.com/posts/cake-12s-set-class-eats-arrays-for-breakfast
And also check out this site: http://www.cakephp.nu/quick-tutorial-cakephp-set-class-part-1

Thu, Mar. 20th, 2008, 12:15 am
generateList() disappeared in CakePHP 1.2

After a couple of days of messing about with CakePHP, I have decided to move on to 1.2 (beta). There are a lot more functions in the newer version than the old. The problem is that there's even LESS documentation.

The Model::generateList() disappeared in CakePHP 1.2.x :( This was a handy function to generate key/value pairs from tables for stuff like a drop down, or radio button. The following two calls should work:
var $uses = array('Model1', 'Status');
...
$tmpVals = $this->Status->findAll(array('context' => '= users'));
$tmpVals = Set::combine($tmpVals, '{n}.Status.id', '{n}.Status.name');
This is assuming that your Status table contains the fields 'id', and 'name' which would be the <.. value= ..> and the plain text description, respectively.