#6268: 'contain' left my model unbound?
    Reporter:  conrad.leonard       |          Type:  Bug    
      Status:  new                  |      Priority:  Medium 
   Milestone:  1.2.x.x              |     Component:  General
     Version:  1.2 Final            |      Severity:  Normal 
    Keywords:  contain containable  |   Php_version:  PHP 5  
Cake_version:                       |  
 I have 5 models related by:
 Question belongsTo QuestionSet and hasMany (Response, Choice)
 QuestionSet hasMany (Question, ResponseSet)
 ResponseSet belongsTo QuestionSet and hasMany (Response)
 Response belongsTo (Question, ResponseSet)
 Choice belongsTo Question

 In my response_sets_controller 'edit' function I have:

 $this->data = $this->ResponseSet->find('first',array(

 which is great, returns just what I want. Then in my corresponding
 edit.ctp view I have a cached element that requests some stuff from the

         $fetchedStuff = $this->requestAction("/questions/view/".$qid);

 where the code in questions_controller view function explicitly asks for
 related Choices:

         if (isset($this->params['requested'])){
                 return $this->Question->find('first', array(
                         'contain'=> array(
                         'conditions'=> array('Question.id'=>$id)));

 but the first time the element makes the request NO Choices are returned.
 On subsequent requests however (the element is repeated in the view)
 Choices ARE returned. Is this a bug, or some weird scope thing? It
 certainly isn't what I expected (or wanted). At the moment I must
 workaround by manual rebind of Question model after the initial find with

Ticket URL: <https://trac.cakephp.org/ticket/6268>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

  • [CakePHP : The Rapid Dev... CakePHP : The Rapid Development Framework for PHP

Reply via email to