为什么rules验证规则不生效? [ 2.0 版本 ]
模型代码
class BankMark extends \yii\db\ActiveRecord
{
/**
 * {@inheritdoc}
 */
public static function tableName()
{
    return 'table_bank_mark';
}
/**
 * {@inheritdoc}
 */
public function rules()
{
    return [
        ['real_name',  'required', 'message'=>'开户姓名不能为空!'],
/* [['bank_mark'], 'string', 'max' => 50],
        [['bank_name'], 'string', 'max' => 60],
        [['bank_mark'], 'unique'],*/
    ];
}
控制器代码
if (($model = UserBank::findOne($id)) === null) {
     throw new NotFoundHttpException('The requested page does not exist.');
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['list']);
} else {
return $this->render('userbankupdate', [
         'model' => $model,
       ]);
}
视图代码

我想问的是为什么我real_name 这个字段留空,始终不走模型的rules 验证规则呢?
而且real_name这个提交的值填写后,还都验证通过了,save()也修改成功,但是值却没有修改到,这个是什么问题呢?
共 0 个回答
没有找到数据。
landong66
            注册时间:2015-01-29
最后登录:2020-04-16
在线时长:9小时3分
    最后登录:2020-04-16
在线时长:9小时3分
- 粉丝2
 - 金钱115
 - 威望0
 - 积分205