Skip to content

Commit 6d7a968

Browse files
Merge pull request #2 from lichunqiang/fix-multiple-field-pk
[bugfix] Fixed can not save bug when model's primary key is multiple.
2 parents 9144b9f + 948c3bb commit 6d7a968

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

EditableAction.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function run()
5656
$class = $this->modelClass;
5757
$pk = Yii::$app->request->post('pk');
5858
$attribute = Yii::$app->request->post('name');
59-
//For attributes with format - relationName.attributeName
59+
//For attributes with format - relationName.attributeName
6060
if (strpos($attribute, '.')) {
6161
$attributeParts = explode('.', $attribute);
6262
$attribute = array_pop($attributeParts);
@@ -69,7 +69,7 @@ public function run()
6969
throw new BadRequestHttpException("Value cannot be empty.");
7070
}
7171
/** @var \Yii\db\ActiveRecord $model */
72-
$model = $class::findOne([$this->pkColumn => $pk]);
72+
$model = $class::findOne(is_array($pk) ? $pk : [$this->pkColumn => $pk]);
7373
if (!$model) {
7474
if ($this->forceCreate) { // only useful for models with one editable attribute or no validations
7575
$model = new $class;
@@ -93,4 +93,4 @@ public function run()
9393
}
9494
}
9595

96-
}
96+
}

0 commit comments

Comments
 (0)