I have a survey form at my website and since the survey is quite long I put it on two pages. The first twelve questions are saved to the database and after that the next twelve questions are saved. But that means that two records are added to the database. I want to save it to the same record not two different records. How can this be done? Each template is saved with a method in the controller that looks like this.
public function survey() {
$survey = $this->Surveys->newEmptyEntity();
if ($this->request->is('post')) {
$survey = $this->Surveys->patchEntity($survey, $this->request->getData());
if ($this->Surveys->save($survey)) {
$this->Flash->success(__('The survey has been saved.'));
return $this->redirect(['action' => 'survey2']);
}
$this->Flash->error(__('The survey could not be saved. Please, try again.'));
}
$this->set(compact('survey'));
}