Ok, this is in a component that my controller uses. I've also had the
virtual field assignment in the controller with identical results. I'd
rather have it here in the component.

               // assign the virtual field
               $modelObj->virtualFields = array ('name' =>
"CONCAT($modelObj->primaryKey, \": \", $modelObj->displayField)");

                // do the find
                $select_list = $modelObj->find('list', array(
                    //'fields' => array($modelObj->primaryKey,
$modelObj->displayField),
                    'fields' => array($modelObj->primaryKey,
"indexed_name"),
                    'order'=>'lft desc',
                    'recursive' => 2));
Don

On Feb 19, 2:11 pm, John Andersen <[email protected]> wrote:
> Please show the actual code where you assign/define the virtualFields,
> as your example does not look correct at first view!
>
> Are you using MySQL or PostgreSQL?
>
> Enjoy,
>    John
>
> On Feb 19, 10:50 pm, dreamingmind <[email protected]> wrote:
>
> > I'm trying to create a virtual field to use in find('list') on the Aro
> > model in cakes Acl component. Since I'd rather not mess with the Acl
> > files directly, I created the virtual field in a controller when I
> > needed it, something like this:
>
> >  Aro->virtualFields = array ('name' => "CONCAT(id, \": \", alias)");
>
> > This does create the virtual field, but not in the array with the
> > other fields. Here's what I get:
>
> > Array
> > (
> >     [Aro] => Array
> >         (
> >             [id] => 1
> >             [parent_id] =>
> >             [model] => Group
> >             [foreign_key] => 1
> >             [alias] => administrators
> >             [lft] => 1
> >             [rght] => 4
> >         )
>
> >     [0] => Array
> >         (
> >             [Aro__name] => 1: administrators
> >         )
>
> > This makes the find('list') result return a set of empty elements.
>
> > If I edit the Aro model directly to create the virtual field like
> > this:
>
> >         var $virtualFields = array(
> >             'indexed_name' => 'CONCAT(Aro.id, ": ", Aro.alias)'
> >         );
>
> > I get what I would expect:
>
> > Array
> > (
> >     [Aro] => Array
> >         (
> >             [id] => 1
> >             [parent_id] =>
> >             [model] => Group
> >             [foreign_key] => 1
> >             [alias] => administrators
> >             [lft] => 1
> >             [rght] => 4
> >             [indexed_name] => 1: administrators
> >         )
>
> > That doesn't seem like a good solution though. Any suggestions?
>
> > Don

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to