开发者

How to add multiple entries of same object into session in cakePHP

开发者 https://www.devze.com 2023-02-15 13:49 出处:网络
I have a addstudent.ctp fileto add students echo $this->Form->create(\'Student\'); echo $this->Form->input(\'FirstName\');

I have a addstudent.ctp file to add students

echo $this->Form->create('Student');
echo $this->Form->input('FirstName');
echo $this->Form->input('LastName');
echo $this-&开发者_如何学Pythongt;Form->end('Register'); 

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

after clicking on it is going to add method of StudentsController.it has to add student object to session and should redirect to same page.like this i can able to add as many students as possible ,so my problem is to how to add the multiple students into session whenever clicks on register button.


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

精彩评论

暂无评论...
验证码 换一张
取 消