2011-03-09 19 views
0

我有一個addstudent.ctp文件點擊它之後添加學生如何同一個對象的多個條目添加到會話在CakePHP

echo $this->Form->create('Student'); 
echo $this->Form->input('FirstName'); 
echo $this->Form->input('LastName'); 
echo $this->Form->end('Register'); 

echo $this->Form->create('Address',array('controller'=>'addresses','action'=>'addaddress')); 
echo$this->Form->end('NextAdressDetails',array('controller'=>'addresses','action'=>'addaddress')); 

是要增加StudentsController.it的方法來增加學生對象到會議,並應重定向到同一頁面。就像我可以添加儘可能多的學生,所以我的問題是如何添加多個學生到會話中,只要點擊註冊按鈕。

回答

0
$students = $this->Session->read('Students'); 
if (!$students) { 
    $students = array(); 
} 
$students[] = /* data */; 
$this->Session->write('Students', $students); 
相關問題