Santa, First I am using 1.2 so there might be some differences some where with the way generateList / scaffold work. However, I guess the key functionality and the end result should be the same.
> So why would I need a completely new model for each section? By defining the Letter model as you / I proposed, virtually (to cake) we have set up 3 models with different names (Opening, Middle and Ending), yet using the same class (LetterContent). This is confirmed by looking at the SQL statements created by generateList (when debug is on). See below. > While reviewing the Scaffold, I can see that it is purely vanilla. If > you reference a model, it will pull that model without conditions or > variation. So I can see why the conditions get bypassed when using > scaffolding, the scaffolding ignores them. :( But I still do not > understand why the model can't handle that situation Like you, I had thought the conditions we set for the model should be taken into account. I had expected generateList follow findAll pattern of being 'controlled' by the condition set for the model. However, it is how it functions, so... just accept it for now and make it work by manually giving correct conditions for generateList. If it works for openings it should work for other sections... Try turning on debug and make sure the SQL statements for other sections are 'the same' as for openings (mine are, and they look as follows). SELECT `LetterContent`.`id` FROM `letter_contents` AS `LetterContent` WHERE `letter_section` = 'Opening' SELECT `LetterContent`.`id` FROM `letter_contents` AS `LetterContent` WHERE `letter_section` = 'Middle' SELECT `LetterContent`.`id` FROM `letter_contents` AS `LetterContent` WHERE `letter_section` = 'Ending' If you like I can forward to you the complete code I used for testing out this case. Good luck, Zonium On Dec 12, 9:59 pm, Santa <[EMAIL PROTECTED]> wrote: > AD7six said: > > > OR consider scaffolding what it is (a development tool), bake/write > > some code and add the conditions to the generateList call as you would > > need to do for any polymorphic model definition. if you use 3 models > > opperating on the same table, just edit the model's beforeFind to add > > a condition to only return rows with 'type' = middle (for example). > > I'm not sure how this would be any different than what I am trying to > accomplish with the Letter and LetterContent model? I am setting up > the filter using the 'condition' in the relationship $belongsTo. (see > below) So why would I need a completely new model for each section? > Shouldn't the condition do the filtering for me and only provide the > data specified by the filter 'condition' back to the controller? or am > I missing something? > > Unless I am misreading the code, the findAll function in the AppModel > (model_php5.php) passes the condition to the beforeFind function by > default so I shouldn't have to write 3 models defining the filter in a > beforeFind option for each one. The condition should already cover > that. > > While reviewing the Scaffold, I can see that it is purely vanilla. If > you reference a model, it will pull that model without conditions or > variation. So I can see why the conditions get bypassed when using > scaffolding, the scaffolding ignores them. :( But I still do not > understand why the model can't handle that situation even in a > scaffold environment. The request from the controller should always > filter through the model and return what the model is intending, not a > vanilla flavor the scaffold selects. If I am off on this, someone > please explain it to me. Even the lifecycle shows the scaffold is but > a small method used to render basic controller functions / views to > use with the model. (http://www.cakecollab.org/lifecycle.png) It still > appears the model is responsible for the data that is returned to the > controller. > > LETTER MODEL > <?php > class Letter extends AppModel { > var $name = 'Letter'; > var $belongsTo = array( > 'Opening' => > array('className' => 'LetterContent', > 'conditions' => > "letter_contents.letter_section = 'Opening'", > 'order' => '', > 'foreignKey' => 'opening_id' > ), > 'Middle' => > array('className' => 'LetterContent', > 'conditions' => > "letter_contents.letter_section = 'Middle'", > 'order' => '', > 'foreignKey' => 'middle_id' > ), > 'Ending' => > array('className' => 'LetterContent', > 'conditions' => > "letter_contents.letter_section = 'Ending'", > 'order' => '', > 'foreignKey' => 'ending_id' > ), > );} > > ?> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---