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

Doesn't save new parent and related models #18

Open
equa2k9 opened this issue Mar 19, 2018 · 0 comments
Open

Doesn't save new parent and related models #18

equa2k9 opened this issue Mar 19, 2018 · 0 comments

Comments

@equa2k9
Copy link

equa2k9 commented Mar 19, 2018

Hello, I have a little issue:
There are two models: User and UserInfo, relation one-to-one.
User:
public function getInfo() { return $this->hasOne(UserInfo::className(), ['user_id' => 'id']); }
Info:
public function getUser() { return $this->hasOne(User::className(), ['id' => 'user_id']); }

when I try to post data:
{ "username": "admin2", "email": "admin@demo32.com", "phone": "+380666818275", "firstname": "Live23", "lastname": "fff23", "country_code": "UA", "role": "status": 10, "info": { "mail_country": "USA", "mail_address1": "Address1", "mail_address2": "Address 2", "mail_city": "City", "mail_state": "State", "mail_zip": "123456", "date_start": null, "date_end": null, "deposit_direct": 1, "text_info": "text info", "text_bullet": "text bullet", "text_short": "text short", "text_readmore": "text readmore", "photo": null, "g_ppm": null, "a_ppm": null } }
I have an error:
"name": "Relation exception", "message": "Owner-model admin\\models\\User not saved due to unknown error", "code": 0, "type": "notamedia\\relation\\RelationException", "file": "/home/oles/liveadvisor-api3/vendor/notamedia/yii2-relation/RelationBehavior.php", "line": 317,

But when I update user & userinfo (with user_id field), it's working well.
Can you help?

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

No branches or pull requests

1 participant