Home

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.

Fri, Mar. 21st, 2008 11:25 am (UTC)
(Anonymous): Not accurate

It's been deprecated, it hasn't disappeared and is replaced by find('list')
see:
https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/model/model.php?rev=6592#L2194

The example given can be simplified to:
$conditions = array('context' => 'users');
$tmpVals = $this->Status->find('list', compact('conditions'));