Forget about storing the id in a session and just include the field in the form. Cake will automatically hide it from the user.
On Jun 18, 8:55 am, Jon Chin <[email protected]> wrote: > I'm building a scholarship application using Cake. I have an > Application model and a Merit model and I'm using a wizard component I > picked up from the Bakery. The Application model has a hasOne > relationship to Merit. I want my users to be able to come back to edit > the stuff they've already saved to the merits table. My app works fine > the first time a user goes through the process. The problem I'm having > is that when they want to edit the data (btw, it loads the data from the > db fine), it attempts to insert a new record rather than update the > current. Here's my relevant code: > > In the controller: > $this->Merit->id = $this->Session->read('application_id');//I've done a > pr($this->Merit->id); and it is has the right application id > if($this->Merit->save($this->data)) {return true;} > > In the model: > var $name = 'Merit'; > var $belongsTo = array('Application' => array( > 'className' => 'Application', > 'foreignKey' => 'application_id' > )); > > Any advice would be greatly appreciated. I've been banging my head on > the wall over this. > > Thanks, > > -- > Jon Chin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
