cakePHP: Filter selected list by variable
- by gonzela2006
I'm on cakePHP 2. I have a problem and I need your help. Here is some code of my controller(StudentsController.php) specifically "edit" function:
$students = $this -> Student -> find('list', array(
'order' => 'Student.name ASC'
));
$this -> set('students', $students);
How can I filter the list by the current student's class?? so the list will contain all students that has the same student's class
I need some code like this
$students = $this -> Student -> find('list', array(
'conditions' => array('Student.class_id' => CURRENT-STUDENT'S-CLASS),
'order' => 'Student.name ASC'
));
$this -> set('students', $students);
Please Advise
Thanks,
gonzela2006