Hi all,
I am trying to build a page that uses a parent model (Game) and child
models (Score). Game has the following fields: id, game_number, and
date. Score has the following fields: player_id, player_finish,
player_points, and game_id. In my scenario, there should always be 10
Score(s) per Game. I'd like to have the player_id, player_finish, and
player_points rendered on the page when the "Add New Game" link is
clicked. I've defined my Score fields as follows:
<tr>
<td>1</td>
<td><?php echo $html->input('Score/player_id', array('size' => '4'))?
></td>
<td><?php echo $html->input('Score/player_points', array('size' =>
'4','value' => $valueOne))?>
</<?php echo $html->hidden('Score/player_finish', array('value' =>
'1')); ?>
</tr>
<tr>
<td>2</td>
<td><?php echo $html->input('Score/player_id', array('size' => '4'))?
></td>
<td><?php echo $html->input('Score/player_points', array('size' =>
'4','value' => $valueTwo))?></td>
<?php echo $html->hidden('Score/player_finish', array('value' =>
'2')); ?>
</tr>
I don't think this is correct. In the save, the Game array ($this-
>data['Game']) does not contain ANY of the score domains. The last
Score model defined on my view is being saved. The manual says:
These same basic techniques will work if you're saving multiple child
models, just place those save() calls in a loop (and remember to clear
the model information using Model::create()).
I tried this code thinking it would save two Score models, but it
simply inserts one record and then updates the same record:
$gameID = $this->Game->getLastInsertId();
$this->data['Score']['game_id'] = $gameID;
$this->Game->Score->save($this->data);
$this->create();
$gameID = $this->Game->getLastInsertId();
$this->data['Score']['game_id'] = $gameID;
$this->Game->Score->save($this->data);
I'm stuck. Any thoughts would be awesome.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---