Tuesday, May 3, 2011

Re: ็How To send data form Controller to other Model

Assuming that Myprofile is associated with Member, the code in
MembersController should be:

$this->Member->Myprofile->whatever()

On Sun, May 1, 2011 at 5:58 PM, taq <taqmaninw@gmail.com> wrote:
>  create view for register and send data to controller
> //app::import('Model','Myprofile');
>     Class MembersController extends AppController{
>    var $name = 'Members';
> var $helpers = array('Form','Session');
> var $uses = array('Myprofile');//
>
>   function register(){
> //$myprofile = new Myprofile();
>  if(!empty ($this->data)){
>     $this->Member->create();
>       if($this->Member->save(($this->data['Member']['username']),
> ($this->data['Member']['password']))
>             &&  $this->Myprofile->save(($this->data['Myprofile']
> ['name']),($this->data['MyProfile']['address']),($this-
>>data['Myprofile']['phonenumber'])))
>        {
>                    $this->redirect('index');
>         }
>    }
>
>       else {
>
>             $this->Session->setFlash('failed');
>    }
>
>  }
> I want to send data form memberscontroller to Myprofile Model
>  I try to use $use = array('Myprofile');
> i got Undefined property: MembersController::$Member when
>  I use //app::import('Model','Myprofile'); //$myprofile = new
> Myprofile()
>  i got Undefined property: MembersController::$Myprofile
> I do not know the right way or not
>  There is also another way to fix my problem
> Thank for any advice
>
> --
> 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
>

--
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: