为什么我会遇到这些错误:?

问题描述:

我的错误代码是:为什么我会遇到这些错误:?

Notice: Undefined variable: form in c:\AppServ\www\applogic\app\views\users\index.ctp on line 1

Fatal error: Call to a member function create() on a non-object in c:\AppServ\www\applogic\app\views\users\index.ctp on line 1))) (index.ctp)

<?php echo $form->create(null, array('action' => 'index'));?> 
<fieldset> 
<legend>Enter Your Name</legend> 
<?php echo $form->input('name'); ?> 
</fieldset> 
<?php echo $form->end('Go');?> 

(users_controller.php中)

<?php 
class UsersController extends AppController { 
var $name = 'Users'; 
var $uses = array(); 
function index() { 
if (!empty($this->data)) { 
//data posted 
echo $this->data['name']; 
$this->autoRender = false; 
} 
} 
} 
?> 

你设置app_controller或users_controller的$佣工?你需要在其中包含'表格'。 如果您使用2.0,我认为您需要使用$ this-> Html(不是$ html)

+0

@我使用v 2.0并使用$ this-> Html,但注意到发生了 – magy