Re: Multiple field values in select box?

2007-08-14 Thread Geoff Ford
Try $listdata[$data['Team']['team']] = $data['Sport']['sport'] . '-' .
$data['Team']['team'];

This missing square bracket you put in the wrong place.

Geoff

On 8/14/07, Beertigger [EMAIL PROTECTED] wrote:


 Thanks, Geoff,

 I caught that one earlier, also found what I think was a missing ] to
 close the

 $listdata[$data['Team']['team'] = $data['Sport']['sport'] . '-' .
 $data['Team']['team'];

 now: $listdata[$data['Team']['team'] = $data['Sport']['sport'] . '-' .
 $data['Team']['team']];

 Still no smiles from heaven for this one


 Beertigger

 On Aug 13, 7:30 pm, Geoff Ford [EMAIL PROTECTED] wrote:
  You've got a error in the getListData function - remove the curly barce
  between the end of the query and $listdata = array();
 
  Geoff
 
  On 8/14/07, Beertigger [EMAIL PROTECTED] wrote:
 
 
 
   Found this one earlier. What myGenerateList does, it does very well,
   much easier than using an afterFind to concat things. But, from what I
   can tell thus far, it has the same limitation, in that it can't
   combine data across two models and display it in a third.
 
   On Aug 13, 2:58 pm, cdomigan [EMAIL PROTECTED] wrote:
   
 http://php-coding-practices.com/cakephp-specific/how-to-put-combined-...
 
  --http://lemoncake.wordpress.com


 



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



Re: Multiple field values in select box?

2007-08-14 Thread Beertigger


Excellent!

Contrary to my earlier post, a href=http://php-coding-practices.com/
cakephp-specific/how-to-put-combined-fields-into-cakephps-model-
generatelist/myGenerateList/a does work across Models!



Tim Koschützki has really come up with a great one here.

Thanks to all who helped me out with this one!



Beertigger


On Aug 14, 6:34 am, Beertigger [EMAIL PROTECTED] wrote:
 Not... enough... caffeine...

 Thanks /chagrin

 On Aug 14, 4:11 am, Geoff Ford [EMAIL PROTECTED] wrote:

  Try $listdata[$data['Team']['team']] = $data['Sport']['sport'] . '-' .
  $data['Team']['team'];

  This missing square bracket you put in the wrong place.

  Geoff

  On 8/14/07, Beertigger [EMAIL PROTECTED] wrote:

   Thanks, Geoff,

   I caught that one earlier, also found what I think was a missing ] to
   close the

   $listdata[$data['Team']['team'] = $data['Sport']['sport'] . '-' .
   $data['Team']['team'];

   now: $listdata[$data['Team']['team'] = $data['Sport']['sport'] . '-' .
   $data['Team']['team']];

   Still no smiles from heaven for this one

   Beertigger

   On Aug 13, 7:30 pm, Geoff Ford [EMAIL PROTECTED] wrote:
You've got a error in the getListData function - remove the curly barce
between the end of the query and $listdata = array();

Geoff

On 8/14/07, Beertigger [EMAIL PROTECTED] wrote:

 Found this one earlier. What myGenerateList does, it does very well,
 much easier than using an afterFind to concat things. But, from what I
 can tell thus far, it has the same limitation, in that it can't
 combine data across two models and display it in a third.

 On Aug 13, 2:58 pm, cdomigan [EMAIL PROTECTED] wrote:

  http://php-coding-practices.com/cakephp-specific/how-to-put-combined-...

--http://lemoncake.wordpress.com

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



Re: Multiple field values in select box?

2007-08-13 Thread Beertigger



Back at this after a coupla days away - thanks much for all the input.

Still having trouble with something entirely too basic. Based on
Geoff's last input, here's my current code:

In controller:

function getListData($data){
$data = $this-Model-query(SELECT Team.team as 
`Team`,`team` ,
Team.id as `Team`,`id` , Sport.sport as `Sport`,`sport` FROM `Teams`
as Team, `Sports` as Sport, WHERE `Team`.`sport_id` = `Sport`.`id`);
}

$listdata = array();
foreach ($data as $item) {
$listdata[$data['Team']['team'] = 
$data['Sport']['sport'] . '-' .
$data['Team']['team'];
}
return $listdata;
}


In 'add' function:

$this-set('listdata', $this-Player-getListData());


In the view:


 echo $html-selectTag(Player/team, $listdata);

I get:

With the $listdata = array section:

Parse error: syntax error, unexpected T_VARIABLE, expecting
T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/xx/
controllers/players_controller.php on line 371 ($listdata = array)

Comment that bit out, and:

SQL Error: 1064: You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'getlistdata' at line 1 in /home/x/cake/libs/
model/datasources/dbo_source.php on line 463



On Aug 9, 11:20 pm, Geoff Ford [EMAIL PROTECTED] wrote:
 function getListData($data){
$data = $this-Model-query(SELECT Model1.field1 as `Model1`,`field1` ,
 Model1.field2 as `Model1`,`field2` , Model2.field1 as `Model2`,`field1`
 FROM `bars` as Model1, `barbars` as Model2, WHERE `Model2`.`barbar_id` =
 `Model1`.`id`);
  }

$listdata = array();
foreach ($data as $item) {
$listdata[$data['Model1']['field1'] = $data['Model1']['field1'] . '-'
 . $data['Model2']['field1'];
}

  return $listdata;

 }

 and later, in the 'add' function:

 $this-set('listdata', $this-Model-getListData());

 In the view:

 echo $html-selectTag(Player/team, $teamsportlist);

 Not tested but should work.

 Geoff
 --http://lemoncake.wordpress.com

 On 8/10/07, Beertigger [EMAIL PROTECTED] wrote:





  Still trying to concat data from two models into a select list in a
  third.

  Thanks for the help thus far, Geoff. Taking your advice, and some
  input from IRC, after much trying, I'm at:

  In controller:

   function getListData($data){
  $data = $this-Model-query(SELECT CONCAT(bar, ' - ', barbar) AS
  foobar
  FROM `bars` , `barbars` WHERE `bar`.`barbar_id` = `barbar`.`id`);
  return $data;
}

  $listdata = array();
  foreach ($data as $item) {
  $listdata[$data]['Model']['foo'] = $data['Model2']['bar'] .
  '-' .
  $data['Model3']['barbar'];
  }

  and later, in the 'add' function:

  $this-set('listdata', $this-Model-getListData());

  In the view:

  echo $html-selectTag(Player/team, $teamsportlist, $selectedItems);

  None of this seems to be working, no matter how I jigger things about.
  Aargh!

  --Beertigger

  On Aug 8, 6:59 pm, Geoff Ford [EMAIL PROTECTED] wrote:
   All the code I outlined would be in the controller.  You could put the
  loop
   in the getListData() function in the model if you like to keep the
   controller cleaner.  The controller would then just be
   $this-set('listdata', $this-Model-getListData());

   Geoff

   On 8/9/07, Beertigger [EMAIL PROTECTED] wrote:

Somehow, this seems on the right track, but I couldn't get things to
work. Played around with a lot of different variations, but
*something* is not quite kosher, yet.

Thanks much for the guidance thus far.

Should the entire

$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];

}

be in the Model?

And the this-set in the controller?

Sorry for my blatant stupidity. Wrapping what I know of php up with
Cake is proving to be troublesome, at best. The masterbake script
provides such a sweet basic framework that a bit of pain getting
things 'just right' is worth it, but this one thing is really killing
me... ; )

On Aug 8, 3:48 pm, Geoff Ford [EMAIL PROTECTED] wrote:
 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){

Re: Multiple field values in select box?

2007-08-13 Thread cdomigan

http://php-coding-practices.com/cakephp-specific/how-to-put-combined-fields-into-cakephps-model-generatelist/


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



Re: Multiple field values in select box?

2007-08-13 Thread Beertigger

Found this one earlier. What myGenerateList does, it does very well,
much easier than using an afterFind to concat things. But, from what I
can tell thus far, it has the same limitation, in that it can't
combine data across two models and display it in a third.



On Aug 13, 2:58 pm, cdomigan [EMAIL PROTECTED] wrote:
 http://php-coding-practices.com/cakephp-specific/how-to-put-combined-...


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



Re: Multiple field values in select box?

2007-08-13 Thread Geoff Ford
You've got a error in the getListData function - remove the curly barce
between the end of the query and $listdata = array();

Geoff


On 8/14/07, Beertigger [EMAIL PROTECTED] wrote:


 Found this one earlier. What myGenerateList does, it does very well,
 much easier than using an afterFind to concat things. But, from what I
 can tell thus far, it has the same limitation, in that it can't
 combine data across two models and display it in a third.



 On Aug 13, 2:58 pm, cdomigan [EMAIL PROTECTED] wrote:
  http://php-coding-practices.com/cakephp-specific/how-to-put-combined-...


 



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



Re: Multiple field values in select box?

2007-08-13 Thread Beertigger

Thanks, Geoff,

I caught that one earlier, also found what I think was a missing ] to
close the

$listdata[$data['Team']['team'] = $data['Sport']['sport'] . '-' .
$data['Team']['team'];

now: $listdata[$data['Team']['team'] = $data['Sport']['sport'] . '-' .
$data['Team']['team']];

Still no smiles from heaven for this one


Beertigger

On Aug 13, 7:30 pm, Geoff Ford [EMAIL PROTECTED] wrote:
 You've got a error in the getListData function - remove the curly barce
 between the end of the query and $listdata = array();

 Geoff

 On 8/14/07, Beertigger [EMAIL PROTECTED] wrote:



  Found this one earlier. What myGenerateList does, it does very well,
  much easier than using an afterFind to concat things. But, from what I
  can tell thus far, it has the same limitation, in that it can't
  combine data across two models and display it in a third.

  On Aug 13, 2:58 pm, cdomigan [EMAIL PROTECTED] wrote:
  http://php-coding-practices.com/cakephp-specific/how-to-put-combined-...

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



Re: Multiple field values in select box?

2007-08-10 Thread Geoff Ford
function getListData($data){
   $data = $this-Model-query(SELECT Model1.field1 as `Model1`,`field1` ,
Model1.field2 as `Model1`,`field2` , Model2.field1 as `Model2`,`field1`
FROM `bars` as Model1, `barbars` as Model2, WHERE `Model2`.`barbar_id` =
`Model1`.`id`);
 }

   $listdata = array();
   foreach ($data as $item) {
   $listdata[$data['Model1']['field1'] = $data['Model1']['field1'] . '-'
. $data['Model2']['field1'];
   }

 return $listdata;
}

and later, in the 'add' function:

$this-set('listdata', $this-Model-getListData());

In the view:

echo $html-selectTag(Player/team, $teamsportlist);

Not tested but should work.

Geoff
--
http://lemoncake.wordpress.com

On 8/10/07, Beertigger [EMAIL PROTECTED] wrote:


 Still trying to concat data from two models into a select list in a
 third.

 Thanks for the help thus far, Geoff. Taking your advice, and some
 input from IRC, after much trying, I'm at:

 In controller:

  function getListData($data){
 $data = $this-Model-query(SELECT CONCAT(bar, ' - ', barbar) AS
 foobar
 FROM `bars` , `barbars` WHERE `bar`.`barbar_id` = `barbar`.`id`);
 return $data;
   }

 $listdata = array();
 foreach ($data as $item) {
 $listdata[$data]['Model']['foo'] = $data['Model2']['bar'] .
 '-' .
 $data['Model3']['barbar'];
 }

 and later, in the 'add' function:

 $this-set('listdata', $this-Model-getListData());

 In the view:

 echo $html-selectTag(Player/team, $teamsportlist, $selectedItems);

 None of this seems to be working, no matter how I jigger things about.
 Aargh!

 --Beertigger



 On Aug 8, 6:59 pm, Geoff Ford [EMAIL PROTECTED] wrote:
  All the code I outlined would be in the controller.  You could put the
 loop
  in the getListData() function in the model if you like to keep the
  controller cleaner.  The controller would then just be
  $this-set('listdata', $this-Model-getListData());
 
  Geoff
 
  On 8/9/07, Beertigger [EMAIL PROTECTED] wrote:
 
 
 
 
 
   Somehow, this seems on the right track, but I couldn't get things to
   work. Played around with a lot of different variations, but
   *something* is not quite kosher, yet.
 
   Thanks much for the guidance thus far.
 
   Should the entire
 
   $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];
 
   }
 
   be in the Model?
 
   And the this-set in the controller?
 
   Sorry for my blatant stupidity. Wrapping what I know of php up with
   Cake is proving to be troublesome, at best. The masterbake script
   provides such a sweet basic framework that a bit of pain getting
   things 'just right' is worth it, but this one thing is really killing
   me... ; )
 
   On Aug 8, 3:48 pm, Geoff Ford [EMAIL PROTECTED] wrote:
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
 
  --http://lemoncake.wordpress.com


 



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



Re: Multiple field values in select box?

2007-08-09 Thread Beertigger

Still trying to concat data from two models into a select list in a
third.

Thanks for the help thus far, Geoff. Taking your advice, and some
input from IRC, after much trying, I'm at:

In controller:

 function getListData($data){
$data = $this-Model-query(SELECT CONCAT(bar, ' - ', barbar) AS
foobar
FROM `bars` , `barbars` WHERE `bar`.`barbar_id` = `barbar`.`id`);
return $data;
  }

$listdata = array();
foreach ($data as $item) {
$listdata[$data]['Model']['foo'] = $data['Model2']['bar'] .
'-' .
$data['Model3']['barbar'];
}

and later, in the 'add' function:

$this-set('listdata', $this-Model-getListData());

In the view:

echo $html-selectTag(Player/team, $teamsportlist, $selectedItems);

None of this seems to be working, no matter how I jigger things about.
Aargh!

--Beertigger



On Aug 8, 6:59 pm, Geoff Ford [EMAIL PROTECTED] wrote:
 All the code I outlined would be in the controller.  You could put the loop
 in the getListData() function in the model if you like to keep the
 controller cleaner.  The controller would then just be
 $this-set('listdata', $this-Model-getListData());

 Geoff

 On 8/9/07, Beertigger [EMAIL PROTECTED] wrote:





  Somehow, this seems on the right track, but I couldn't get things to
  work. Played around with a lot of different variations, but
  *something* is not quite kosher, yet.

  Thanks much for the guidance thus far.

  Should the entire

  $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];

  }

  be in the Model?

  And the this-set in the controller?

  Sorry for my blatant stupidity. Wrapping what I know of php up with
  Cake is proving to be troublesome, at best. The masterbake script
  provides such a sweet basic framework that a bit of pain getting
  things 'just right' is worth it, but this one thing is really killing
  me... ; )

  On Aug 8, 3:48 pm, Geoff Ford [EMAIL PROTECTED] wrote:
   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

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



Re: Multiple field values in select box?

2007-08-08 Thread Beertigger

Form::select is 1.2 only, no? I'm using 1.1

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!


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



Re: Multiple field values in select box?

2007-08-08 Thread Beertigger


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!


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



Re: Multiple field values in select box?

2007-08-08 Thread Geoff Ford
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 

Re: Multiple field values in select box?

2007-08-08 Thread Beertigger

Somehow, this seems on the right track, but I couldn't get things to
work. Played around with a lot of different variations, but
*something* is not quite kosher, yet.

Thanks much for the guidance thus far.

Should the entire

$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];

}

be in the Model?

And the this-set in the controller?

Sorry for my blatant stupidity. Wrapping what I know of php up with
Cake is proving to be troublesome, at best. The masterbake script
provides such a sweet basic framework that a bit of pain getting
things 'just right' is worth it, but this one thing is really killing
me... ; )



On Aug 8, 3:48 pm, Geoff Ford [EMAIL PROTECTED] wrote:
 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



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



Re: Multiple field values in select box?

2007-08-08 Thread Geoff Ford
All the code I outlined would be in the controller.  You could put the loop
in the getListData() function in the model if you like to keep the
controller cleaner.  The controller would then just be
$this-set('listdata', $this-Model-getListData());

Geoff

On 8/9/07, Beertigger [EMAIL PROTECTED] wrote:


 Somehow, this seems on the right track, but I couldn't get things to
 work. Played around with a lot of different variations, but
 *something* is not quite kosher, yet.

 Thanks much for the guidance thus far.

 Should the entire

 $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];

 }

 be in the Model?

 And the this-set in the controller?

 Sorry for my blatant stupidity. Wrapping what I know of php up with
 Cake is proving to be troublesome, at best. The masterbake script
 provides such a sweet basic framework that a bit of pain getting
 things 'just right' is worth it, but this one thing is really killing
 me... ; )



 On Aug 8, 3:48 pm, Geoff Ford [EMAIL PROTECTED] wrote:
  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
 


 



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



Multiple model fields in generatelist, was: Multiple field values in select box?

2007-08-01 Thread Beertigger

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!


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



Re: Multiple field values in select box?

2007-08-01 Thread Beertigger

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



Re: Multiple field values in select box?

2007-08-01 Thread Beertigger

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!


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



Re: Multiple field values in select box?

2007-07-28 Thread cauld

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



Multiple field values in select box?

2007-07-27 Thread Beertigger


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/50a2ecaf2e14f4eb/cc46362244303c7c?lnk=gstq=%24column+%3D%3E+%24valuernum=48#cc46362244303c7c


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