OK so use HtmlHelper::select() or selectTag() - I can't remember of the top
of my head which one it is.  My solutions is still the same - creat the
array that you want to display in the listbox manually.

Again not sure of the exact array format but something like

$data = $this->Model->getListData(); // a function in your model that does
the custom query to pull the three fields you wnat to use
$mylist = array();
foreach ($data as $item){
  $mylist[$data['Model']['field1]] = $data['Model']['field2] . '-' .
$data['Model']['field3];
}

$this->set("mylist", $mylist);


Then in your view something like (again double check the format)

$html->select("SelectName", $mylist, $selectedItems);

I hope this helps :)

Geoff

On 8/9/07, Beertigger <[EMAIL PROTECTED]> wrote:
>
>
>
> Isn't form::select for 1.2? I'm using 1.1 on this project...
>
>
> On Aug 8, 3:05 am, Geoff Ford <[EMAIL PROTECTED]> wrote:
> > Forget generateList(). Create the array yourself to pass to
> > Form::select() using a custom query if necessary.
> >
> > Sometimes when you are doing something that is a little bit out of the
> > ordinary it can be too hard to make it "Cakeish" and it is easier and
> > simpler to do the old php way. :)
> >
> > Geoff
> > --http://lemoncake.wordpress.com
> >
> > On Aug 8, 4:37 pm, Beertigger <[EMAIL PROTECTED]> wrote:
> >
> > > I must be far more retarded than the average bear, b/c this is
> > > something I just can't get working in Cake.
> >
> > > I can get the results I want with a basic sql query:
> >
> > > SELECT CONCAT(team, ' - ', sport)
> > > AS teamsport FROM `teams` , `sports` WHERE `teams`.`sport_id` =
> > > `sports`.`id`
> >
> > > when I run it on the db.
> >
> > > But I can't for the life of me suss out how to frost this up. Should I
> > > put the query in the model, or the controller. How do I set things up
> > > to use generateList with a findBySql or query? I've searched high and
> > > low and  high again and can't find any clear-cut code examples for
> > > this.
> >
> > > If you've got the patience to help me out, I will at the least owe you
> > > a virtual pint!
> >
> > > Slainte!
> >
> > > On Aug 1, 9:51 pm, Beertigger <[EMAIL PROTECTED]> wrote:
> >
> > > > Anyone? I'm pulling my hair out here. This is something that should
> be
> > > > basic, shouldn't it? I'll freely admit I'm an idiot, but I'm just
> not
> > > > understanding this.... ; (
> >
> > > > Thanks to anyone willing to point me in the right direction.
> >
> > > > On Aug 1, 9:38 am,Beertigger<[EMAIL PROTECTED]> wrote:
> >
> > > > > 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!
>
>
> >
>


-- 
http://lemoncake.wordpress.com

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