THINKPHP添加不能为空
<?php namespace Admin\Controller; use Think\Controller; class TypeController extends Controller { //加载栏目列表页面 public function showlist(){ $this->display(); } //加载添加栏目页面 public function tianjia(){ if(IS_POST){ $data['typename']=I('typename'); $type=D('type'); if($type->create($data)){ if($type->add($data)){ $this->success('栏目添加成功',U('showlist'),2); } else{ $this->error('栏目添加失败'); }} else{ $this->error($type->getError()); } return; } $this->display(); } //加载修改栏目页面 public function xiugai(){ $this->display(); } }
Model代码
<?php namespace Admin\Model; use Think\Model; class TypeModel extends Model { protected $_validate=array( array('typename','require','栏目名称不能为空'), ); }