#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( 'contain'=>array( 'QuestionSet'=>array( 'Question'=>array( 'Response'=>array('conditions'=>array('response_set_id'=>$id))))), 'conditions'=>array( 'ResponseSet.id'=>$id))); }}} 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 questions_controller: {{{ $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( 'Choice'), '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 'contain'. -- 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 flexibility. --~--~---------~--~----~------------~-------~--~----~ 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 tickets-cakephp+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/tickets-cakephp?hl=en -~----------~----~----~----~------~----~------~--~---