Topic: FormHelper -->Notice: Undefined variable: form
Scusate, sto cercando di addentrarmi in questo framework che trovo fatto bene.
Ho seguito le direttive da manuale sia per l'installazione che per il codice di un semplice blog. Quello che non riesco a capire è perchè sulle funzioni edit e add mi da questo errore
Notice: Undefined variable: form in C:\xampp\htdocs\cake\app\views\games_players\add.ctp on line 3
Fatal error: Call to a member function create() on a non-object in C:\xampp\htdocs\cake\app\views\games_players\add.ctp on line 3
// \app\views\games_players\add.ctp
<h1>Aggiungi partita</h1>
<?php
echo $form->create('GamesPlayer');
echo $form->input('si_no');
echo $form->input('note', array('rows' => '3'));
echo $form->end('Save Post');
?>mentre il controller
//\app\controllers\games_players_controller.php
<?php
class GamesPlayersController extends AppController {
var $components = array('pagination', 'Session');
var $name = 'GamesPlayers';
function index() {
$this->set('GamesPlayers', $this->GamesPlayer->findAll());
}
function view($id) {
$this->GamesPlayer->id = $id;
$this->set('GamesPlayers', $this->GamesPlayer->read());
}
function add() {
if (!empty($this->data)) {
if ($this->GamesPlayer->save($this->data)) {
$this->flash('Your post has been saved.','/games_players');
}
}
}
function delete($id) {
$this->GamesPlayer->del($id);
$this->flash('The post with id: '.$id.' has been deleted.', '/games_players');
}
function edit($id = null) {
$this->GamesPlayer->id = $id;
if (empty($this->data)) {
$this->data = $this->GamesPlayer->read();
} else {
if ($this->GamesPlayer->save($this->data)) {
$this->flash('Your post has been updated.','/games_players');
}
}
}
}
?>Premetto che tutte le altre funzioni , elenco , vedi dettaglio e cancella funzionano.
Dev'essere un problema del FormHelper.
Ho dimenticato di fare qualcosa?![]()
davide