谁能告诉我为什么我$model->load(Yii::$app->request->post()返回布尔值 (false) ?我尝试 var_dump $model->load(Yii::$app->request->post(),它肯定有我的输入值(不为空)。
这是我的代码。我正在处理基于Vitalet's x-editable. 该字段将修改tema数据库列的值(tema的模型属性)。我尝试print_r($model->getErrors())在'else'语句中,我得到了
Array
(
)
public function actionFetch(){
//There's only a single row in the table.
$model= Home::find()->one();
if (Yii::$app->request->isAjax) {
// use Yii's response format to encode output as JSON
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
// save posted model attributes
if ($model->load(Yii::$app->request->post()) && $model->save()) {
//extract the class name
$modelClassName = \yii\helpers\StringHelper::basename(get_class($model));
//grab the post parameters array (as attribute=>value)
$params = Yii::$app->request->post($modelClassName);
//pull the …Run Code Online (Sandbox Code Playgroud)