Good Day

I am still very very new to CakePHP and I have gained tons of respect for 
it, but I having a problem with $hasAndBelongsToMany .

The issue I am having is the  echo $this->Form->input('TypesGames'); 
Displays nothing but an input empty Box,

<https://lh3.googleusercontent.com/-Obe-CWdL5gA/VgkpyuWowwI/AAAAAAAA3JM/bxW25H1RKcc/s1600/inputbox.png>



but if I do an print_r on the $TypesGames the array displays all 
my TypesGame I get an return eg: 

        Array
(
    [1] => soccer
    [2] => tennis
    [3] => cricket
)


Please can someone help

Many Thanks
Daniel

Here is my code:

*model/game.php*

public $hasAndBelongsToMany = array(
'TypesGame' => array(
'className' => 'TypesGame',
'joinTable' => 'linked_gametypes',
'foreignKey' => 'types_games_id',
'associationForeignKey' => 'games_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
)
);

*Controller/GamesController.php*

public function add() {
if ($this->request->is('post')) {
$this->Game->create();
if ($this->Game->save($this->request->data)) {
$this->Session->setFlash(__('The game has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The game could not be saved. Please, try 
again.'));
}
}
$TypesGames = $this->Game->TypesGame->find('list');
$venues = $this->Game->Venue->find('list');
$cities = $this->Game->Cities->find('list');
$this->set(compact('venues', 'cities','TypesGames'));
}

* View/Games/add.ctp*

<?php echo $this->Form->create('Game'); ?>
<fieldset>
<legend><?php echo __('Add Game'); ?></legend>
<?php
echo $this->Form->input('venue_id');
echo $this->Form->input('GameName');
echo $this->Form->input('info');
echo $this->Form->input('price');
echo $this->Form->input('TypesGames');
echo $this->Form->input('dateStart');
echo $this->Form->input('dateEnd');
echo $this->Form->input('timeStart');
echo $this->Form->input('timeEnd');
echo $this->Form->input('cities_id');
?>
</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to