Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cake PHP:使用表单帮助程序时出现未定义的错误_Php_Cakephp - Fatal编程技术网

Cake PHP:使用表单帮助程序时出现未定义的错误

Cake PHP:使用表单帮助程序时出现未定义的错误,php,cakephp,Php,Cakephp,我是cakePHP新手,我只是尝试创建一个简单的表单,在视图上有一个文本框和一个提交按钮,并在控制器上使用post数据显示文本 我的视图代码: <?php echo $form->create(null, array('action' => 'index'));?> <fieldset><legend>Enter Your Name</legend><?php echo $form->input('name'); ?>

我是cakePHP新手,我只是尝试创建一个简单的表单,在视图上有一个文本框和一个提交按钮,并在控制器上使用post数据显示文本

我的视图代码:

<?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');?> 
这里面有什么问题


提前感谢。

$form->method
来自CakePHP的旧版本。在新版本中,表单帮助程序是
$this->form->method
。因此,只需在代码中替换这些实例:

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

输入您的姓名
像这样

<div class="login"> 
<h2>Login</h2>     
    <?php 

    echo $this->Form->create('User', array('action' => 'login'));?> 
        <?php echo $this->Form->input('username');?> 
        <?php echo $this->Form->input('password');?> 
        <?php echo $this->Form->submit('Login');?> 
    <?php echo $this->Form->end(); ?> 
</div>

登录

非常感谢Ben先生。有关于最新CakePHP版本的教程吗。
<?php echo $this->Form->create(null, array('action' => 'index'));?>
<fieldset><legend>Enter Your Name</legend><?php echo $this->Form->input('name'); ?></fieldset>
<?php echo $this->Form->end('Go');?> 
<div class="login"> 
<h2>Login</h2>     
    <?php 

    echo $this->Form->create('User', array('action' => 'login'));?> 
        <?php echo $this->Form->input('username');?> 
        <?php echo $this->Form->input('password');?> 
        <?php echo $this->Form->submit('Login');?> 
    <?php echo $this->Form->end(); ?> 
</div>