Thanks, both of them works, but I prefer Burns way. So here's what I do :
//in ApplicantsController
function process() {
        if(array_key_exists('confirm',$this->params['form'])) {
                $this->ApprovedApplicant->set($this->data['Applicant']);
                if($this->ApprovedApplicant->save()) {
                                
                        $applicantId = $this->ApprovedApplicant->id;
                        $docsArray =
array('document_number'=>'aaa','approved_applicant_id'=>$applicantId);
                        $this->Document->add($docsArray);       
                }
}

//in Documents model
function add($docsArray) {
                
                $this->set($docsArray);
                $this->save();
                return true;
        }




Zaky Katalan-Ezra wrote:
> 
> As a variable to add function
> 
> in DocumentsController
> function add($applicantId = null) {
>    //get newly inserted applicant id
>   //save applicant data to documents table
> }
> 
> in ApplicantsController
> function process() {
>          ...
>          ...
>          //redirect to DocumentsController and pass newly inserted
> applicant
> id
>          $this->redirect(array('controller' => 'documents',
> action'=>'add',$applicantId));
>        }
> }
> 
> 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
> 
> To unsubscribe, reply using "remove me" as the subject.
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Passing-variable-from-a-controller-to-another-controller-tp28160538p28186449.html
Sent from the CakePHP mailing list archive at Nabble.com.

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