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