I might be wrong about this, but the fields array pertains to just the
main model. If you add Containable to your behaviors, you can do this:

$this->set(
        'visibleprojects',
        $this->Project->find(
                'all',
                array(
                        'conditions'=>array('Project.visible'=>1),
                        'fields'=>array('Project.title'),
                        'contain' => array(
                                'Category' => array(
                                        'fields' => array(
                                                'Category.name'
                                        )
                                )
                        )
                )
        )
);

Note that recursive becomes unnecessary. You can leave off the model
name in the fields arrays but Cake will be adding it in anyway when it
builds the query, so I like to save a few cycles and put in myself. It
makes for easier reading, also.

Also, you should use arrays here:

var $hasAndBelongsToMany = array('Project');
var $hasAndBelongsToMany = array('Category');

On Thu, Mar 26, 2009 at 9:01 PM, thalund <[email protected]> wrote:
>
> It's all very simple since I was just beginning building:
>
> models/category.php :
>
> class Category extends AppModel {
>
>  var $name = 'Category';
>
>  var $actsAs = array('Tree');
>  var $hasAndBelongsToMany = 'Project';
>
> }
>
> models/project.php
>
> class Project extends AppModel {
>  var $name = 'Project';
>
>  var $hasAndBelongsToMany = 'Category';
>
> }
>
> On 25 Mar., 21:06, mscdex <[email protected]> wrote:
>> Post your Project and Category models, especially theHABTMvariable
>> in each.
> >
>

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