La comunità italiana su CakePHP

You are not logged in. Please login or register.


Pages: 1

Atom RSS

Posts [ 5 ]

by_spix

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?
roll
davide

Saiborg

Re: FormHelper -->Notice: Undefined variable: form

Stai usando la 1.2 vero?

Può essere che l'helper FormHelper non venga caricato di default come l'HtmlHelper (almeno così pare dalla documentazione).
Nel controller prova ad aggiungere la riga

var $helpers = array('Form', 'Html');

by_spix

Re: FormHelper -->Notice: Undefined variable: form

Si è la 1.2
Ho inserito la riga, e ora mi da questo messaggio

Fatal error: Call to undefined method FormHelper::create()

grazie cmq per la tempestività

by_spix

Re: FormHelper -->Notice: Undefined variable: form

Hai ragione, avevo in realtà scaricato la 1.1. Con l'ultima relase funziona, scusate big_smile

Namaless

Re: FormHelper -->Notice: Undefined variable: form

by_spix wrote:

Hai ragione, avevo in realtà scaricato la 1.1. Con l'ultima relase funziona, scusate big_smile

Difatti con CakePHP 1.1 l'helper "Form" non esiste tongue

Posts [ 5 ]

Guest posting is disabled. You must login or register to post a reply.

Pages: 1

Topic info

1 guests and 0 users are reading this topic now


Forum quick jump menu

Currently used extensions: pun_topic_online_users, pun_karma, pun_admin_hook_navigator, pun_bbcode. Copyright © 2008 PunBB

[ Generated in 0.032 seconds, 10 queries executed ]