Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions EditableAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function run()
$class = $this->modelClass;
$pk = Yii::$app->request->post('pk');
$attribute = Yii::$app->request->post('name');
//For attributes with format - relationName.attributeName
//For attributes with format - relationName.attributeName
if (strpos($attribute, '.')) {
$attributeParts = explode('.', $attribute);
$attribute = array_pop($attributeParts);
Expand All @@ -69,7 +69,7 @@ public function run()
throw new BadRequestHttpException("Value cannot be empty.");
}
/** @var \Yii\db\ActiveRecord $model */
$model = $class::findOne([$this->pkColumn => $pk]);
$model = $class::findOne(is_array($pk) ? $pk : [$this->pkColumn => $pk]);
if (!$model) {
if ($this->forceCreate) { // only useful for models with one editable attribute or no validations
$model = new $class;
Expand All @@ -93,4 +93,4 @@ public function run()
}
}

}
}