douliandan7340 2011-01-11 21:14
浏览 102
已采纳

与CakePHP一起使用HtmlHelper时出现错误信息

Brand-new CakePHP user; just got the install up and running a few hours ago (or so I thought.) I've been running through the blog tutorial and everything was going swimmingly, until I hit the Adding Posts section. I thought maybe I had made a typo somewhere, so I copied and pasted the code directly out of the tutorial, and I'm still getting these errors when I try to go to localhost/cakeBlogTest/posts/add. Can anyone help me out? I installed the most recent stable version of CakePHP.

Warning (512): Method HtmlHelper::input does not exist [CORE/cake/libs/view/helper.php, line 143]

Warning (512): Method HtmlHelper::tagErrorMsg does not exist [CORE/cake/libs/view/helper.php, line 143]

Warning (512): Method HtmlHelper::textarea does not exist [CORE/cake/libs/view/helper.php, line 143]

Warning (512): Method HtmlHelper::submit does not exist [CORE/cake/libs/view/helper.php, line 143]

EDITED TO ADD:

I was able to use $html->link in another section of the tutorial, so it does seem to be finding the helpers file. I just looked at the helper file, and input, textarea, and submit do exist, but tagErrorMsg does not. Is it possible the tutorial is out-of-date and using bits that no longer exist in the current version of CakePHP? And if so, what do I use in place of tagErrorMsg?

MORE ADDITIONS:

Code copy/pasted directly from tutorial:

<h1>Add Post</h1>
<form method="post" action="<?php echo $html->url('/posts/add')?>">
    <p>
        Title:
        <?php echo $html->input('Post/title', array('size' => '40'))?>
        <?php echo $html->tagErrorMsg('Post/title', 'Title is required.') ?>
    </p>
    <p>
        Body:
        <?php echo $html->textarea('Post/body', array('rows'=>'10')) ?>
        <?php echo $html->tagErrorMsg('Post/body', 'Body is required.') ?>
    </p>
    <p>
        <?php echo $html->submit('Save') ?>
    </p>
</form>
  • 写回答

2条回答 默认 最新

  • dpztth71739 2011-01-11 21:20
    关注

    input, textarea, submit are not functions of HtmlHelper they belong to FormHelper

    In your views you should use $this->Form->input('test') instead of $this->Html->input('test')

    This tutorial belongs to cakephp v1.1 (obviously out-of-date)

    Learn cakePHP's latest tutorial v1.3

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元