/*适用情况:比如提交一个表单,提交完成之后在页面展示一条提示消息. 控制器里面这样写: 单条消息: */ \Yii::$app->getSession()->setFlash('error', 'This is the message'); \Yii::$app->getSession()->setFlash('success', 'This is the message'); \Yii::$app->getSession()->setFlash('info', 'T…
YII 表单的验证可以在module目录下的xxx.php里面定义验证方法,设定需要验证的字段就行 //用户表单验证,在模型里面设置一个方法,具体表单验证规则 public function rules(){ return array( array("name","required",'message'=>'用户名必填'), array("password…
/** * Validates the specified object. * @param \yii\base\Model $model the data model being validated * @param array|null $attributes the list of attributes to be validated. * Note that if an attribute is not associated with the validator - it will be…