I have the following relations between my models
Program hasMany Classroom
Classroom belongsTo Program
What I am trying to achieve is to display all the classrooms, grouped by program, for example:
Program 1
-Classroom 1
-Classroom 2
-Classroom 3
Program 2
-Classroom 1
-Classroom 2... etc
My index action in ClassroomsController:
function index() {
$this->Access->grantAdmin();
$this->Classroom->recursive = 1;
$this->set('classrooms', $this->paginate());
}
I tried to use this:
var $paginate = array(
'group' => 'program_id'
);
But it didn't work as I expected. Any ideas? Thanks