I
I
Ivan Yakushenko2016-07-17 20:16:09
Yii
Ivan Yakushenko, 2016-07-17 20:16:09

Why doesn't findOne by id work?

Function:

public function editdata()
    {

        $user = User::findOne($this->id);
        $user->username = $this->username;
        $user->email = $this->email;
        $user->fio = $this->fio;
        $user->apartment = $this->apartment;
        $user->house = $this->house;
        $user->housing = $this->housing;
        $user->street = $this->street;
        $user->phone = $this->phone;
        $user->setPassword($this->password);

        return $user->save() ? $user : null;

    }

Mistake:
Getting unknown property: app\models\EditdataForm::id

What's wrong with User::findOne($this->id); ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lander, 2016-07-18
@kshnkvn

If you need the current user, then

$user = User::findOne(Yii::$app->user->identity->id);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question