|
|
@ -44,9 +44,22 @@ class Attribute extends \yii\db\ActiveRecord |
|
|
|
[['value'], 'string'], |
|
|
|
[['type', 'sort_order', 'is_delete', 'cat_id'], 'integer'], |
|
|
|
[['name'], 'string', 'max' => 50], |
|
|
|
[['sort_order'], 'checkNegative'], |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param $attribute |
|
|
|
* @param $params |
|
|
|
* 验证是否为负数 |
|
|
|
*/ |
|
|
|
public function checkNegative($attribute, $params) |
|
|
|
{ |
|
|
|
if ((integer)$this->$attribute < 0) { |
|
|
|
$this->addError($attribute, "不得为负数"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* {@inheritdoc} |
|
|
|
*/ |
|
|
|