We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, I'm trying to use your EditableColumn, but with related model's attribute:
[ 'class' => EditableColumn::class, 'attribute' => 'image.alt', 'url' => ['update-related-alt'], ],
Currently your code doesn't allow such use.
I fixed this as follows:
Method run():
run()
public function run() { $model = $this->findModelOrCreate(); $attribute = $this->getModelAttribute(); if ($this->preProcess && is_callable($this->preProcess, true)) { call_user_func($this->preProcess, $model); } $model->setScenario($this->scenario); $value = Yii::$app->request->post('value'); $attributeParts = explode('.', $attribute); $relatedModel = $model; foreach ($attributeParts as $attributePart) { $relatedModel = $relatedModel->$attributePart; } $relatedModel = $value; if ($model->validate([$attribute])) { return $model->save(false); } else { throw new BadRequestHttpException($model->getFirstError($attribute)); } }
And the method getModelAttribute():
getModelAttribute()
private function getModelAttribute() { $attribute = Yii::$app->request->post('name'); /*if (strpos($attribute, '.')) { $attributeParts = explode('.', $attribute); $attribute = array_pop($attributeParts); }*/ if ($attribute === null) { throw new BadRequestHttpException('Attribute cannot be empty.'); } return $attribute; }
The text was updated successfully, but these errors were encountered:
Hi, I figured out that this is fixed in dev-master, but not in any stable release. Maybe you add a new release to Composer?
dev-master
Sorry, something went wrong.
No branches or pull requests
Hi, I'm trying to use your EditableColumn, but with related model's attribute:
Currently your code doesn't allow such use.
I fixed this as follows:
Method
run()
:And the method
getModelAttribute()
:The text was updated successfully, but these errors were encountered: