Tuesday, March 20, 2012

Why recursive attr not working in latest Cake 2.1??

I have a controller action index(),and two models . Problem is that
'questions' variable
line 1 just pull only its data ,doesnot pull associated Model Answer
data ,
this code works in 1.3 but not work in 2.0


Controller Action ::

function index(){
//This not work in cake 2.1
//$this->Question->recursive = 1;

line 1. $this->set('questions', $this->Question-
>find('all',array('recursive' => 1)));

}


2 models


class Answer extends AppModel {

public $name ='Answer';
public $belongsTo=array(
'Question'=>array(
'className'=>'Question'
)
);

}


class Question extends AppModel {

public $name ='Question';
public $hasMany = array(
'Answer' =>array(
'className'=>'Answer'
)
);
}

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: