I am having a model class in my Yii2-advanced application which was having some attributes.
public function rules()
{
return [
[['SESSION_TITLE', 'SESSION_DESCRIPTION', 'TRAINER_ID'], 'required'],
[['TRAINER_ID','IS_ACTIVE', 'IS_DELETED'], 'integer'],
];
}
Now, I need to add an attribute TNI_NUMBER in model which I already have added in database table with similar spellings. After adding in model.
public function rules()
{
return [
[['SESSION_TITLE', 'SESSION_DESCRIPTION', 'TRAINER_ID'], 'required'],
[['TRAINER_ID','TNI_NUMBER' ,'IS_ACTIVE', 'IS_DELETED'], 'integer'],
];
}
The form is showing Getting Unknown Property on that specific attribute, on loading the form right after adding this attribute. Note that the data type of attribute in model and in database is not an issue. And the database connection array has set 'enableSchemaCache' => true in it and it can't be set to false.
This worked for me, added it before calling model class in controller action.
NOTE: this is for one-time usage only, once page refreshed after adding this line, do remember to comment or remove it.