Property "user.phone" Is Not Defined.

Hi,

I am new in yii and I have configured test drive application in our yii framework and it’s working properly. I added new field phone in create newuser page, it’s display me on create newuser page but when i submit the page it’s show the below error. Please help me to sort out this basic issue.

Error–>

Property "User.phone" is not defined.

F:\xampp\htdocs\yiiframework\framework\db\ar\CActiveRecord.php(144)

132 */

133 public function __get($name)

134 {

135 if(isset($this->_attributes[$name]))

136 return $this->_attributes[$name];

137 else if(isset($this->getMetaData()->columns[$name]))

138 return null;

139 else if(isset($this->_related[$name]))

140 return $this->_related[$name];

141 else if(isset($this->getMetaData()->relations[$name]))

142 return $this->getRelated($name);

143 else

144 return parent::__get($name);

145 }

146

147 /**

148 * PHP setter magic method.

149 * This method is overridden so that AR attributes can be accessed like properties.

150 * @param string $name property name

151 * @param mixed $value property value

152 */

153 public function __set($name,$value)

154 {

155 if($this->setAttribute($name,$value)===false)

156 {

Stack Trace

#0

  • F:\xampp\htdocs\yiiframework\framework\db\ar\CActiveRecord.php(144): CComponent->__get("phone")

#1

  • F:\xampp\htdocs\yiiframework\framework\web\helpers\CHtml.php(2044): CActiveRecord->__get("phone")

#2

  • F:\xampp\htdocs\yiiframework\framework\web\helpers\CHtml.php(1774): CHtml::resolveValue(User, "phone")

#3

  • F:\xampp\htdocs\yiiframework\framework\web\helpers\CHtml.php(1205): CHtml::activeInputField("text", User, "phone", array("size" => 60, "maxlength" => 128, "name" => "User[phone]", "id" => "User_phone"))

#4

  • F:\xampp\htdocs\yiiframework\framework\web\widgets\CActiveForm.php(575): CHtml::activeTextField(User, "phone", array("size" => 60, "maxlength" => 128))

#5

– F:\xampp\htdocs\testdrive\protected\views\user\_form.php(32): CActiveForm->textField(User, "phone", array("size" => 60, "maxlength" => 128))

27 <?php echo $form->error($model,‘email’); ?>

28 </div>

29

30 <div class="row">

31 <?php echo $form->labelEx($model,‘phone’); ?>

32 <?php echo $form->textField($model,‘phone’,array(‘size’=>60,‘maxlength’=>128)); ?>

33 <?php echo $form->error($model,‘phone’); ?>

34 </div>

35

36 <div class="row buttons">

37 <?php echo CHtml::submitButton($model->isNewRecord ? ‘Create’ : ‘Save’); ?>

Did you also add "phone" field to the "user" in your database?

If, yes, then could you post the code of your User model?

do that again as follow:

a. modify the database table

b. delete the user model and rebuild it with Gii

c. delete the userController and its view file under the dir views/user/*.php, and then rebuild the CRUD with Gii

d. take a look at if it works or not

do that again as follow:

a. modify the database table

b. delete the user model and rebuild it with Gii

c. delete the userController and its view file under the dir views/user/*.php, and then rebuild the CRUD with Gii

d. take a look at if it works or not

Thanks for your quick response.

Actually I am not able to see the database in Phpmyadmin that’why I m not able to add the column. this is the file path of database file F:\xampp\htdocs\testdrive\protected\data. Please let me know how can i configure and add new column in database.

Use SQLite Manager extensions for firefox

https://addons.mozilla.org/vi/firefox/addon/sqlite-manager/

The table "tbl_user" for active record class "User" cannot be found in the database.

F:\xampp\htdocs\yiiframework\framework\db\ar\CActiveRecord.php(2264)

I suggest that you had better read the yii guide before you go on.

http://www.yiiframework.com/doc/guide/

Thanks all of you to provide your support and suggestion…