2018-05-06 13:46:24 1850次浏览 3条回答 0 悬赏 10 金钱

['uid', 'unique', 'targetClass' => \common\models\AutoComplete::className(), 'targetAttribute' => ['uid', $this->_branch => 'branch_id'], 'message' => '编号已经存在',]

这么配置的unique验证器targetClass参数无效,还是会使用当前类的table验证

php版本7.2.5
yii2.0.15

  • 回答于 2018-05-07 09:15 举报

    换个用法试试

    ['username', 'unique', 'targetClass' => '\common\models\Member', 'message' => '该用户名已使用'],
    
    1 条回复
    回复于 2018-05-07 23:18 回复

    还是不行啊,还是会使用当前model的tablename

    觉得很赞
  • 回答于 2018-05-09 17:32 举报
    [['uid'], 'unique', 'targetClass' =>' \common\models\AutoComplete', 'targetAttribute' => ['uid', $this->_branch => 'branch_id'], 'message' => '编号已经存在',]
        	
    
  • 回答于 2018-05-22 11:36 举报

    这样呢:
    [['uid'], 'unique', 'targetClass' => AutoComplete::class, 'targetAttribute' => ['uid', $this->_branch => 'branch_id'], 'message' => '编号已经存在',]

您需要登录后才可以回答。登录 | 立即注册
jorge
见习主管

jorge

注册时间:2016-10-31
最后登录:2024-03-01
在线时长:15小时25分
  • 粉丝0
  • 金钱90
  • 威望0
  • 积分240

热门问题