留言添加验证失败,json_decode(['status' => false, 'msg' => '发布失败!']);
public function actionAddFeed() { $model = new FeedModel(); $model->content = Yii::$app->request->post('content'); if($model->validate()){ if($model->create()) { return json_encode(['status' => true]); } } return json_decode(['status' => false, 'msg' => '发布失败!']); }
这里json_decode报错
json_encode同样不成功
验证为空才会发表成功
验证规则
public function rules() { return [ [['user_id', 'content', 'created_at'], 'required'], [['user_id', 'created_at'], 'integer'], [['content'], 'string', 'max' => 255] ]; }
想请教下验证哪错了