CakePHP multi-model view

If your using the latest 1.2 code, check out Model::saveAll in the api

eg. Your view might look something like this:

If your using the latest 1.2 code, check out Model::saveAll in the api

eg. Your view might look something like this:

echo $form->create('User', array('action'=>'add'); echo $form->input('User.name'); echo $form->input('Address.line_1'); echo $form->input('Contact.tel'); echo $form->end('Save'); 

Then in your Users controller add method you’d have something like:

...if($this->User->saveAll($this->data)){  $this->Session->setFlash('Save Successful');  $this->redirect(array('action'=>'index')); }else{  $this->Session->setFlash('Please review the form for errors'); }... 

In your User model you will need something like:

var $hasOne = array('Address','Contact'); 

Hope that helps!

http://api.cakephp.org/class_model.html#49f295217028004b5a723caf086a86b1

From: http://stackoverflow.com/questions/110232/cakephp-multi-model-view

Leave a Reply

Your email address will not be published. Required fields are marked *