php - yii rules how to add validation for a non-database field?
黄舟
黄舟 2017-05-17 09:55:59
0
1
596

For example, I want to add a verification for field A, but it does not exist in the database. An error will be reported at this time. Are there any parameters that can be set?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
小葫芦

Override rulesMethod

class Model extends \yii\db\ActiveRecord
{
    //...
    public function rules() {
        $rules = parent::rules();
        $rules[] = [['phone'],'integer','message'=>'手机号码必须是数字'];
        return $rules;
    }
    //...
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!