i guess you made a mistake

$this->User->set(array('first_name' => 'Donald', 'last_name' =>
'Duck'));

should probably be

$this->User->set(array('User'=>array('first_name' => 'Donald',
'last_name' =>
'Duck')));

in order to access it by "User" key


On 20 Okt., 15:58, Joshua Muheim <[email protected]> wrote:
> I'll take a look at that. Thanks.
>
> Still, this seems to be a bit unclean, doesn't it?
>
> On Wed, Oct 20, 2010 at 3:56 PM, Jeremy Burns | Class Outfit
>
>
>
> <[email protected]> wrote:
> > Or you could just use a virtual field in the model?
>
> > Jeremy Burns
> > Class Outfit
>
> > [email protected]
> >http://www.classoutfit.com
>
> > On 20 Oct 2010, at 14:48, psybear83 wrote:
>
> >> Hi everybody
>
> >> I just stumbled over the following problem.
>
> >> I have a method concatName() in my User model that is called when an
> >> author is validated:
>
> >> function concatName($data) {
> >>    return $data['User']['first_name']." ".$data['User']['last_name'];
> >> }
>
> >> In live action, this works well so far. But in unit tests this doesn't
> >> work:
>
> >>  function testShouldValidateWithValidData() {
> >>    $this->User->set(array('first_name' => 'Donald', 'last_name' =>
> >> 'Duck'));
> >>    $this->assertTrue($this->User->validates());
> >>  }
>
> >> The result is:
>
> >> Unexpected PHP error [Undefined index: User]
>
> >> The reason for this is that in a HTML form, the key in $data is
> >> 'User', but when using set(...) or find(...) the key in $data is
> >> 'user'.
>
> >> Is this a bug? I'm on CakePHP 1.3.4., the newest stable release afaik.
>
> >> Thanks for help,
> >> Josh
>
> >> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
> >> athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
> > athttp://groups.google.com/group/cake-php?hl=en

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