Yii2 active record model not saving data

后端 未结 7 660
情话喂你
情话喂你 2020-12-16 17:47

I\'ve built a simple form model & view, a simple AR model, and a simple controller. The form model assigns the correct values to the AR instance, but when I call save(),

7条回答
  •  Happy的楠姐
    2020-12-16 18:21

    In controller, change your if condition as follow :

    if ($prompt = $model->post() !== null) {
    

    This will validate that the value which is return is not null.
    Your current validation condition is only validating where value is get assigned to variable $prompt or not. And that's why it's always returns true.

提交回复
热议问题