Commit 55b0ece7 authored by Shakarim Sapa's avatar Shakarim Sapa

- Add new validation rule

parent a3852e36
......@@ -81,7 +81,7 @@ class Bid extends \common\components\ActiveRecordModel
[['email'], 'required', 'on' => self::SCENARIO_SUBSCRIBE],
[['email'], 'checkUnique', 'on' => self::SCENARIO_SUBSCRIBE, 'message' => 'Вы уже подписаны на новости блога'],
[['email'], 'unique', 'on' => self::SCENARIO_SUBSCRIBE, 'message' => 'Вы уже подписаны на новости блога'],
[['text'], 'string'],
......@@ -93,16 +93,6 @@ class Bid extends \common\components\ActiveRecordModel
];
}
public function checkUnique($attribute, $params){
if (!is_null($this->$attribute)) {
if (Bid::find()->where([$attribute => $this->$attribute])->exists()===true) {
$this->addError($attribute, $params['message']);
return false;
}
}
return true;
}
/**
* @inheritdoc
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment