|
List Info
Thread: generateList & Saving
|
|
| generateList & Saving |
  United States |
2007-10-16 01:45:11 |
I'm running into problems when i try to customize my fantasy
football
app! I had it working perfectly where players belong to
teams and you
could create new players and select a team from the drop
down, won't
work now.
I can view everything fine, but when I save it doesn't store
the
relationship between my teams and players! I don't know
what I'm
doing wrong and any help would be helpful. Thanks!
<?
class PlayersController extends AppController {
var $name = 'Players
var $uses = array('Team,'Player');
var $scaffold;
function index() {
$this->set('players',$this->Player->findAll());
$this->set('teams',$this->Team->findAll());
}
function add() {
$this->set('teams',$this->Player->Team->generate
List(
null, null, null,
".Team.id", ".Team.name")
);
if (!empty($this->data['Players']))
{
if
($this->Player->save($this->data['Players']))
{
$this->flash('Player added','/players/');
}
}
}
}
?>
--~--~---------~--~----~------------~-------~--~----~
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
cake-php-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: generateList & Saving |
  United States |
2007-10-16 08:21:54 |
Try this:
function add() {
$this->set('teams',$this->Team->generateList(
null, null, null,
".Team.id", ".Team.name")
);
if (!empty($this->data['Player']))
{
if
($this->Player->save($this->data['Player']))
{
$this->flash('Player added','/players/');
}
}
}
Model data is indexed by the singular (data['Player'] not
data['Players']), and since in your controller you're using
Team and
Player there's no need to access team through player
($this->Team
instead of $this->Player)
On Oct 16, 7:45 am, afx <dyna... gmail.com> wrote:
> I'm running into problems when i try to customize my
fantasy football
> app! I had it working perfectly where players belong to
teams and you
> could create new players and select a team from the
drop down, won't
> work now.
>
> I can view everything fine, but when I save it doesn't
store the
> relationship between my teams and players! I don't
know what I'm
> doing wrong and any help would be helpful. Thanks!
>
> <?
> class PlayersController extends AppController {
> var $name = 'Players
> var $uses = array('Team,'Player');
> var $scaffold;
>
> function index() {
>
$this->set('players',$this->Player->findAll());
>
$this->set('teams',$this->Team->findAll());
> }
>
> function add() {
>
$this->set('teams',$this->Player->Team->generate
List(
> null, null, null,
".Team.id", ".Team.name")
> );
> if (!empty($this->data['Players']))
> {
> if
($this->Player->save($this->data['Players']))
> {
> $this->flash('Player added','/players/');
> }
> }
> }}
>
> ?>
--~--~---------~--~----~------------~-------~--~----~
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
cake-php-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: generateList & Saving |
  United States |
2007-10-16 10:06:12 |
This worked. Thanks!
On Oct 16, 6:21 am, grigri <j... hendersonwebdesign.com>
wrote:
> Try this:
>
> function add() {
>
$this->set('teams',$this->Team->generateList(
> null, null, null,
".Team.id", ".Team.name")
> );
> if (!empty($this->data['Player']))
> {
> if
($this->Player->save($this->data['Player']))
> {
> $this->flash('Player added','/players/');
> }
> }
> }
>
> Model data is indexed by the singular (data['Player']
not
> data['Players']), and since in your controller you're
using Team and
> Player there's no need to access team through player
($this->Team
> instead of $this->Player)
>
> On Oct 16, 7:45 am, afx <dyna... gmail.com> wrote:
>
> > I'm running into problems when i try to customize
my fantasy football
> > app! I had it working perfectly where players
belong to teams and you
> > could create new players and select a team from
the drop down, won't
> > work now.
>
> > I can view everything fine, but when I save it
doesn't store the
> > relationship between my teams and players! I
don't know what I'm
> > doing wrong and any help would be helpful.
Thanks!
>
> > <?
> > class PlayersController extends AppController {
> > var $name = 'Players
> > var $uses = array('Team,'Player');
> > var $scaffold;
>
> > function index() {
> >
$this->set('players',$this->Player->findAll());
> >
$this->set('teams',$this->Team->findAll());
> > }
>
> > function add() {
> >
$this->set('teams',$this->Player->Team->generate
List(
> > null, null, null,
".Team.id", ".Team.name")
> > );
> > if (!empty($this->data['Players']))
> > {
> > if
($this->Player->save($this->data['Players']))
> > {
> > $this->flash('Player
added','/players/');
> > }
> > }
> > }}
>
> > ?>
--~--~---------~--~----~------------~-------~--~----~
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
cake-php-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-3]
|
|