37364 2016-07-25 18:47:28 5740次浏览 2条回复 1 0 0

YII2 表单提交 $form->field($model, 'cate_pid') ,不填则默认为null,如何设置为0,而不是Null

$model->load(Yii::$app->request->post())
Integrity constraint violation – yii\db\IntegrityException

SQLSTATE[23000]: Integrity constraint violation: 1048 Le champ 'cate_pid' ne peut être vide (null)
The SQL being executed was: INSERT INTO `yii2b_category` (`cate_pid`, `cate_name`, `cate_title`, `cate_keywords`, `cate_description`, `cate_order`) VALUES (NULL, '测试', '测试', '测试', '测试', 55)
Error Info: Array
(
    [0] => 23000
    [1] => 1048
    [2] => Le champ 'cate_pid' ne peut être vide (null)
)
↵
Caused by: PDOException
您需要登录后才可以回复。登录 | 立即注册