I have one table User (used for the authentication) and linked with a
Student table and Tutor table.
When the "admin" wants to create a tutor, it should add username and
password on the user table.
The tutor table has a foreign key 'iduser'.
Therefore, on the "add method" in the TutorController, I tried to add
an user at the same time as I add a tutor.
But I don't succeed.
Here is the source code :
public function add() {
if ($this->request->is('post')) {
if ($this->Tutor->save($this->request->data)) {
$dataUser = array('username' => $this->request-
>data('LOGINTUTOR'), 'password' => $this->request-
>data('PASSWORDTUTOR'), 'role' => 'tutor');
$this->Tutor->User->save($dataUser);
$this->Tutor->iduser=$this->Tutor->User->id;
$this->Tutor->save($this->request->data);
$this->Session->setFlash('The student has been
saved.');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash('Unable to add the tutor.');
}
}
}
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment