The error message seems to say that ‘qualitativeـcomponent_en’ and ‘qualitativeـcomponent_trans’ are not "name"s … i.e. Yii can’t find such attributes in your model.
Are they from the columns of the table? Or are they public properties of the model? Or something else?
If they are the columns of the table that you have added lately, try clearing the db schema cache.
I checked, every thing was ok. They are my table fields. and as you said i use :
Yii::app()->db->schema->refresh();
in my view action for clearing db cache.
this is my model file class:
<?php
/**
* This is the model class for table "jng_metal".
*
* The followings are the available columns in table 'jng_metal':
* @property string $id
* @property string $type_en
* @property string $type_trans
* @property string $qualitativeـcomponent_en
* @property string $qualitativeـcomponent_trans
* @property string $creatino_time
* @property string $creation_type_en
* @property string $creation_type_trans
* @property string $Weight
* @property string $karat
* @property string $lang
* @property string $create_time
* @property string $update_time
* @property integer $deleted
*
* The followings are the available model relations:
* @property Product[] $products
*/
class MetalBase extends CActiveRecord {
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Metal the static model class
*/
public static function model($className = __CLASS__) {
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName() {
return 'jng_metal';
}
/**
* @return array validation rules for model attributes.
*/
public function rules() {
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('type', 'required'),
array('type', 'numerical'),
array('type', 'in','range'=>array(1,2)),
array('deleted', 'boolean'),
array('qualitativeـcomponent_en, qualitativeـcomponent_trans', 'length', 'max' => 250),
array('creation_type_en, creation_type_trans', 'length', 'max' => 45),
array('Weight, karat', 'length', 'max' => 20),
array('lang', 'length', 'max' => 7),
array('creatino_time, create_time, update_time', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, type,qualitativeـcomponent_en, qualitativeـcomponent_trans, creatino_time, creation_type_en, creation_type_trans, Weight, karat, lang', 'safe', 'on' => 'search'),
);
}
/**
* @return array relational rules.
*/
public function relations() {
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'products' => array(self::HAS_MANY, 'Product', 'metal_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels() {
return array(
'id' => Yii::t('models','metal.id'),
'type' => Yii::t('models','metal.type'),
'qualitativeـcomponent_en' => Yii::t('models','metal.qualitativeـcomponent_en'),
'qualitativeـcomponent_trans' => Yii::t('models','metal.qualitativeـcomponent_trans'),
'creatino_time' => Yii::t('models','metal.creatino_time'),
'creation_type_en' => Yii::t('models','metal.creation_type_en'),
'creation_type_trans' => Yii::t('models','metal.creation_type_trans'),
'Weight' => Yii::t('models','metal.Weight'),
'karat' => Yii::t('models','metal.karat'),
'lang' => Yii::t('models','metal.lang'),
'create_time' => Yii::t('models','metal.create_time'),
'update_time' => Yii::t('models','metal.update_time'),
'deleted' => Yii::t('models','metal.deleted'),
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search() {
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id, true);
$criteria->compare('type', $this->type, true);
$criteria->compare('qualitativeـcomponent_en', $this->qualitativeـcomponent_en, true);
$criteria->compare('qualitativeـcomponent_trans', $this->qualitativeـcomponent_trans, true);
$criteria->compare('creatino_time', $this->creatino_time, true);
$criteria->compare('creation_type_en', $this->creation_type_en, true);
$criteria->compare('creation_type_trans', $this->creation_type_trans, true);
$criteria->compare('Weight', $this->Weight, true);
$criteria->compare('karat', $this->karat, true);
$criteria->compare('lang', $this->lang, true);
$criteria->compare('create_time', $this->create_time, true);
$criteria->compare('update_time', $this->update_time, true);
$criteria->compare('deleted', $this->deleted);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
));
}
}
and this the my extended model class that i use it for my views:
<?php
/**
* This is the model class for table "jng_metal".
*
* The followings are the available columns in table 'jng_metal':
* @property string $id
* @property integer $type
* @property string $qualitativeـcomponent_en
* @property string $qualitativeـcomponent_trans
* @property string $creatino_time
* @property string $creation_type_en
* @property string $creation_type_trans
* @property string $Weight
* @property string $karat
* @property string $lang
* @property string $create_time
* @property string $update_time
* @property integer $deleted
*
* The followings are the available model relations:
* @property Product[] $products
*/
class Metal extends MetalBase {
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Metal the static model class
*/
public static function model($className = __CLASS__) {
return parent::model($className);
}
const GOLD = 1;
const SILVER = 2;
protected function beforeSave() {
if (parent::beforeSave()) {
if ($this->isNewRecord) {
$this->create_time = $this->update_time = date('Y-m-d H:i:s');
} else {
$this->update_time = date('Y-m-d H:i:s');
}
return TRUE;
}
return FALSE;
}
public function getMetals() {
return array(
self::GOLD => Yii::t('models', 'metal.gold'),
self::SILVER => Yii::t('models', 'metal.silver'),
);
}
}
I have copied the above lines to my local text editor, and the character between ‘qulitative’ and ‘component’ is not an ‘_’ (underscore). I’m sure it’s the cause of the problem.
It is the same with the schema definitions:
The character is not expected to be used in a valid ‘name’ when CDetailView interprets the attribute string: