thinkphp使用验证器校验编辑数据,提示重复
![](http://www.cncsto.com/contentimg/4.jpg)
验证器使用了unique保证数据的唯一性,使用验证器验证新增的数据时没有问题,但编辑提交时unique字段无法通过,提示数据重复!
切记,验证编辑数据时,要把主键ID也带上。
$data = $this->request->param(); $data[‘id‘] = $this->userid;//必须带上主键 $result = $this->validate($data, ‘User.editInfo‘);
原文:https://www.cnblogs.com/codeit/p/15097398.html