Multiple model fields in generatelist... ?

Moving this one along a bit....
I've tried every which way to get this one to work, and I'm stumped.
Using afterFind on info from one table works just fine; putting this
in the Player model:
    function afterFind($results) {
         foreach ($results as $key => $val) {
            $results[$key]['Player']['fullname'] =
$val['Player']['fname'] . ' ' . $val['Player']['lname'];
        }
        return $results;
    }
lets me use 'fullname' in controllers easily enough.
How do I get something from another table to concat nicely.
Code like
    function afterFind($results) {
         foreach ($results as $key => $val) {
            $results[$key]['Team']['teamsport'] =
$val['Team']['team'] . ' ' . $val['Sport']['sport'];
        }
        return $results;
    }
only gets me the field from the Team table when it's in the Team
model, and throws a Notice: Undefined index: Sport in...blahblahblah
error.
Team belongsto Sport, Sport hasmany Team
What kinda hoops do I need to jump threw to get this info in a Cake-y
manner? I need to generate a select in another controller. If
somebody'd hold my hand on this one, it'd be greatly appreciated...
Thanks!

On Jul 28, 8:35 am, cauld <[EMAIL PROTECTED]> wrote:
> Not exactly a cake solution, but in the past I've created a database
> view an concatenated the two columns I want in the SQL (ex)
> concat(last_name, ', ', first_name) and then passed the view results
> to generateList().  Perhpas you could do the same with query() and
> pass those results to generateList(), but I've not tried that method
> so can't say it would work, just thinking out loud.  Hope that is
> helpful.
>
> On Jul 27, 11:17 pm,Beertigger<[EMAIL PROTECTED]> wrote:
>
> > Is there any way to get values from multiple fields into a select box?
>
> > After much searching, I've come to the conclusion I'm not going to
> > find the answer without appealing to those far wiser than myself...
>
> > Here's an old thread for reference, which discusses, w/o resolution,
> > exactly what I'm looking for:
>
> > "* Is it possible to use multiple fields to make up the value of the
> > select box?  Such that it would come out looking something like
>
> > <option value='field1value'>field2value - field3value</option>"
>
> >http://groups.google.com/group/cake-php/browse_thread/thread/50a2ecaf...
>
> > So, just wondering if anyone ever made any progress on this. Saw the
> > code in trac, but it seems to be for 1.2 (?). Couldn't get it to work,
> > anyway. I'd find this functionality very valuable....
>
> > Thanks to anyone for any help!


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