Or you could just use a virtual field in the model?

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
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 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to