Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 348
EmmyS Avatar asked Aug 09 '26 16:08

EmmyS


1 Answers

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

like image 158
Ish Avatar answered Aug 11 '26 05:08

Ish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!