Hi,
I am getting the following error when attempting to save my ActiveRecord object.
Unknown Property – yii\base\UnknownPropertyException
Getting unknown property: app\models\User::firstName, lastName, telephone, mobile, information
Here is the model code …
<?php
namespace app\models;
use app\components\ActiveRecord;
class User extends ActiveRecord {
public function rules() {
return [
["email", "required"],
[["firstName, lastName, telephone, mobile, information"], "safe"]
];
}
}
?>
Here is the controller code …
<?php
namespace app\controllers;
use Yii;
use app\components\Controller;
use app\components\ActiveRecord;
use app\models\User;
class UserController extends Controller {
public function actionCreate() {
$user = new User;
if($user->load(Yii::$app->request->post())) {
$password = Yii::$app->security->generateRandomString(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />;
$passwordHash = Yii::$app->security->generatePasswordHash($password);
$user->password = $passwordHash;
$user->save();
return $this->redirect(["user"]);
}
return $this->render("create", [
'models' => [
'user' => $user
]
]);
}
}
?>
Can anyone see what is causing the error?