If you structure your data array correctly you could use one saveAll
command on the instructor table and the 3 models would save.  So your
save code would be reduced to:

if (!empty($this->data)) {
  if ($this->User->Instructor->saveAll($this->data,
array('validate'=>'first'))) {
    $this->Session->setFlash('User saved');
    $this->redirect(array('action'=>'view', $this->User->id));
  } else {
    $this->Session->setFlash('Usernot saved');
  }
}

To do this, you need to get your head around how to use Cake's
automagic to retrieve your HABTM subjects and display them as a
multiple select or checkbox list in your form so the resulting data
structure ends up looking something like

Array
(
    [User] => Array
        (
            [username] => MrInstructor
            [password] => cddb06c93c72f34eb9408610529a34645c29c55d
            [group_id] => 2
        )

    [Instructor] => Array
        (
            [name] => Jimmy Bob
            [email] => [email protected]
            [phone] => 1112223333
            [city] => Beverly Hills
            [zip_code] => 90210
            [states] => 5
            [website] => www.jimmybobschool.com
            [description] => Jimmy Box is an instructor.
            [user_id] => 1
            [id] => 1
        )

    [Subject] => Array
        (
            [Subject] => Array
            (
                [0] => 15 // id for hitting
                [1] => 21 // id for pitching
            )
        )
)

Not read through this blog post fully, but may be of some help:
http://mrphp.com.au/code/working-habtm-form-data-cakephp

HTH

Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to