I apologise if this seems to be a repeat of previous questions but I
haven't been able to find the answer I'm looking for. The example here
is a somewhat simplified for the sake of the post. I have a
CandidatesController that uses both my Candidate and User models. When
registering a new user it needs to insert both the user and then the
candidate. I have included the register method below -
function register()
{
if(empty($this->data)) {
$this->set('candidates', null);
$this->set('users', null);
} else {
$this->cleanUpFields();
if($this->User->save($this->data)) {
$this->data['Candidate']['user_id'] =
$this->User->id;
if($this->Candidate->save($this->data)) {
if(is_object($this->Session)) {
$this->Session->setFlash('The User has
been saved');
$this->redirect($this->viewPath.'/index');
} else {
$this->flash('User saved.',
$this->viewPath.'/index');
}
}} else {
if(is_object($this->Session)) {
$this->Session->setFlash('Please
correct errors below.');
}
}
$data = $this->data;
$this->set('users', $data);
$this->set('candidates', $data);
}
}
This code does the validation in two steps, first when the User is
saved and then again when the Candidate is saved. This is not very
user friendly but I'm not sure what approach to take to resolve this.
I will be very grateful for any suggestions you can make.
Many thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---