开发者

Error message when using HtmlHelper with CakePHP

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>


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


Now the tagErrorMsg function is changed to tagIsInvalid and it is now in "FormHelper" class but before it was in HtmlHelper class.So now onwards we should to use it like-> $this->Form->tagIsInvalid() or $form->tagIsInvalid() AND NOT LIKE $this->Html->tagIsInvalid()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜