Populating a SELECT box with distinct values
Wednesday, December 10th, 2008Let’s say you log events into a database table Log. Attribute event holds event type and you want to filter the log listing just by that.
Here’s what you probably try at first:
-
-
$this->set(‘events’,
-
$this->Log->find(‘list’,
-
It’s not gonna work and you will have to use find(’all’) and Set::combine() to get what you want:
-
-
$events = $this->Log->find(‘all’,
-
$this->set(‘events’,
-
Set::combine($events, ‘{n}.Log.event’, ‘{n}.Log.event’));
-
