namespace Admin\Controller;
use Think\Controller;
class FormController extends Controller{
public function insert(){
$form = D('form');
if($form->create()){
$result = $form->add();
$this->success('数据添加成功!');
}else{
$this->error($from->getError());
}
}
}
模型里写上
namespace Admin\Model;
use Think\Model;
class FormModel extends Model{
//定义自动验证
protected $_validate = array(
array('ti
array('content','require','内容必填'),
);
//定义自动完成
protected $_auto = array(
array('create_time','time',1,'function'),
);
}
然后用form表单填写信息提交到后台。及格过发现要么提交正确显示数据添加成功,要么直接报错:Call to a member function getError() on a non-ob
错误位置
FILE: D:\WWW\thinkphp\Application\Admin\Controller\FormController.class.php LINE: 11
最佳答案