【问题标题】:Why do I get these errors:?为什么我会收到这些错误:?
【发布时间】:2011-08-23 00:13:04
【问题描述】:

我的错误代码是:

注意:未定义变量:form in c:\AppServ\www\applogic\app\views\users\index.ctp 在第 1 行

致命错误:在非对象上调用成员函数 create() c:\AppServ\www\applogic\app\views\users\index.ctp 在第 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;
}
}
}
?>

【问题讨论】:

    标签: cakephp cakephp-1.3 cakephp-1.2


    【解决方案1】:

    您是否在 app_controller 或 users_controller 中设置了 $helpers?您需要在其中包含“表格”。 如果你使用的是 2.0,我认为你需要使用 $this->Html (not $html)

    【讨论】:

    • @我使用 v 2.0 并使用 $this->Html 但注意到发生了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-24
    • 2011-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多