Skip to content
New issue

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

setAttributes doesn't work on save #83

Open
sergeizhukov opened this issue Oct 25, 2019 · 2 comments
Open

setAttributes doesn't work on save #83

sergeizhukov opened this issue Oct 25, 2019 · 2 comments

Comments

@sergeizhukov
Copy link

sergeizhukov commented Oct 25, 2019

Hello!
I have some question.
I make update Event row and the next code is works:

$m = Event::find()->multilingual()->where(['id' => $id])->one();
$m->title = $fd['title'];
$m->save();

But

$m = Event::find()->multilingual()->where(['id' => $id])->one();
$m->setAttributes($fd);
$m->save();

Doesn't save.

$m = Event::find()->multilingual()->where(['id' => $id])->one();
$m->attributes = $fd;
$m->save();

Also doesn't save. Is it correct behaviour?

$m = Event::find()->multilingual()->where(['id' => $id])->one();
foreach ($fd as $key => $val) {
    $m->{$key} = $val;
}
$m->save();

This is again works and save.

@OmgDef
Copy link
Owner

OmgDef commented Oct 26, 2019

Hi! I guess you didn't mention the title attribute in your validation rules in the Event model

@sergeizhukov
Copy link
Author

sergeizhukov commented Oct 29, 2019

Hi! I guess you didn't mention the title attribute in your validation rules in the Event model

You are right. It were dynamically add rules and wasn't this attribute on core model. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants