chanpox
- chanpox 2016-08-01 已签到连续签到12天,获得了20个金钱
- chanpox 回答了问题 yii2中小于1的规则怎么写?
浮点数验证或数字验证
public function rules() { return [ ['discount', 'double','min' => 0.1,'max' => 1], //double可以改为number,两个方法等效 ]; }
- chanpox 2016-07-31 已签到连续签到11天,获得了20个金钱
- chanpox 2016-07-30 已签到连续签到10天,获得了20个金钱
- chanpox 2016-07-29 已签到连续签到9天,获得了20个金钱
- chanpox 2016-07-28 已签到连续签到8天,获得了20个金钱
- chanpox 2016-07-27 已签到连续签到7天,获得了20个金钱
- chanpox 评论了教程 Yii 2 模型中实现属性组合唯一规则验证
我也发一个,用yii\validators\UniqueValidator 类实现
public function rules() { return [ ['name', 'required', 'message' => '请选择门店!'], ['shop_id', 'required', 'message' => '请输入菜品名称!'], ['name', //只有 name 能接收错误提示,数组['name','shop_id']的场合,都接收错误提示 'unique', 'targetAttribute'=>['name','shop_id'] , 'targetClass' => '\models\Dishes', // 模型,缺省时默认当前模型。 'comboNotUnique' => '选择的门店内,该菜品名称已经存在!' //错误信息 ], ]; }
- chanpox 2016-07-26 已签到连续签到6天,获得了20个金钱
- chanpox 2016-07-25 已签到连续签到5天,获得了20个金钱