Example: 
http://teknoid.wordpress.com/2008/09/05/example-of-cakephps-containable-for-deep-model-bindings/
Do you have Containable behavior  included in model (var $actsAs =
array('Containable');) ?

On Oct 6, 8:44 pm, Brenton B <[EMAIL PROTECTED]> wrote:
> uh ... k ...
>
> So for models there's the "find" function, whose first parameter can
> be an assortment of strings depending on what you want to find ...
> well, one of the ones I'm using is "list", which will generate a list
> that's for easier usage in a select list.
> Then there's also the possibility of an array of options as the second
> parameter. One of these possible options is the "contain" key, which,
> when used, would denote what associations to use while doing the find.
> This option doesn't seem to take affect when I use it in conjunction
> with `find('list')`.
> Another thing you an do with the second 'options' array parameter is
> declare how you want the list returned, and what it is to be grouped
> by, for the select list.
>
> In my case, I have a list of States ... I want them grouped by Country
> name .... Therefore, I'm calling it like this:
>
>                         $states = $this->User->State->find('list',
>                                                                 
> array('contain' => array('Country'),
>                                                                         
> 'fields' => array('State.id', 'State.name', 'Country.name')
>                                                                 ));
>
> However, it barks and complains that "Warning (512): SQL Error: 1054:
> Unknown column 'Country.name' in 'field list'", which is because
> 'Country' isn't included int he query ("Query: SELECT `State`.`id`,
> `State`.`name`, `Country`.`name` FROM `states` AS `State`   WHERE 1 =
> 1   ORDER BY `State`.`name` ASC  "), because (I'm assuming) "contain"
> does not work.
>
> If I do `find('all')` (with everything else being the same), it
> returns without error ... albeit, completely screwed up for the select
> list .... if I do 'State.country_id' for the "group" field (3rd in the
> 'fields' array), it returns without error, albeit using the id and not
> the name for the group.
>
> Details added.
>
> Confused or understood?
>
> On Oct 6, 11:27 am, AD7six <[EMAIL PROTECTED]> wrote:
>
> > On Oct 6, 8:20 pm, Brenton B <[EMAIL PROTECTED]> wrote:
>
> > > Apparently doing `find('list')` doesn't like to take into account the
> > > "contain" option.
> > > Is this on purpose?
>
> > > Scenario:
> > > Have a list of States that needs to be grouped by Country name, 2
> > > separate tables where State has the country_id.
>
> > > Bug or intentional?
>
> > Details missing
>
> > deliberate or mistake?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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