Tuesday, March 19, 2013

Re: More than one virtualField

Hi, yes I've seen and read by me, but to be honest I have not yet understood how to use it now in my controller.

i tried this one but it doesn´t help and i get automatically the full_name VirtualField
$this->Event->User->virtualFields['userkennzeichen'];

Am Sonntag, 17. März 2013 17:48:54 UTC+1 schrieb cricket:
On Fri, Mar 15, 2013 at 6:27 AM, Jerome Walitzek
<jerome....@t-online.de> wrote:
> Hi there,
>
> i have more than 12 Models. But for me are only 2 Models important. "User"
> and "Event"
> in the User Model i have set 2 virtualFields
>
> public $virtualFields = array(
>    'full_name' => 'CONCAT(User.vorname, " ", User.nachname)',
>             'userkennzeichen' => 'CONCAT(User.vorname, " ", User.nachname, "
> - Kennzeichen: ", User.einsetzbarin)'
> );
>
>
> Now i try to get the "userkennzeichen" virtualField in a HABTM listing in my
> Event Controller.
>
> How i can do this when i have set conditions too
>
> $drivers = $this->Event->User->find('list', array('conditions' =>
> array('User.role' => 'driver')));

I'm not sure if this has anything to do with it (you didn't post any
error messages) but have a look here:

http://book.cakephp.org/2.0/en/models/virtual-fields.html#limitations-of-virtualfields

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: