Cake PHP:使用表单帮助程序时出现未定义的错误
我是cakePHP新手,我只是尝试创建一个简单的表单,在视图上有一个文本框和一个提交按钮,并在控制器上使用post数据显示文本 我的视图代码: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'); ?>
<?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>