I am wanting to use the following code within my controller which I think the code below is correct:
$user = User::findOne(['username'=>$username]);
$profile = UserProfile::findOne(['user_id' => $user->id]);
// load user data with role and validate them
if ($user->load(Yii::$app->request->post('User')) && $profile->load(Yii::$app->request->post('UserProfile'))) {
However it doesn’t work and goes straight to the else statement below however if I used the below it executes code within the if statement:
if ($user->load(Yii::$app->request->post('_csrf')))
When using var_dump I get the following output which is below, as you can see the User info and UserProfile are nested within is this correct and if so how can I change the first line to work:
array(3) { ["_csrf"]=> string(56) "dsadasdasdasdas==" ["UserProfile"]=> array(3) { ["avatar"]=> string(0) "" ["social"]=> array(3) { ["facebook"]=> string(0) "" ["twitter"]=> string(0) "" ["instagram"]=> string(0) "" } ["bio"]=> string(5) "hello" } ["User"]=> array(3) { ["username"]=> string(22) "fsdfsdfsadminjkhnbnmbb" ["email"]=> string(23) "dasdasdh@yahoo.com" ["password"]=> string(14) "web16prounibar" } }