Getting unknown property error


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 …



	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 …



	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='' class='bbc_emoticon' alt='8)' />;

				$passwordHash = Yii::$app->security->generatePasswordHash($password);


				$user->password = $passwordHash;


				return $this->redirect(["user"]);




			return $this->render("create", [


				'models' => [


					'user' => $user











Can anyone see what is causing the error?

The reason for this was because I did not define the rules array properly.

This …

[["password, firstName, lastName, telephone, mobile, information"], "safe"]

Needed to be this …

[["password", "firstName", "lastName", "telephone", "mobile", "information"], "safe"]

1 Like

this worked for me thanks a lot