Hello,
I have the following scenario:
- A component class:
class MyClass extends CActiveDataProvider{
protected function fetchData() {
$entity = new $this->modelClass;
.....
return $entity->getCompleteEntityRowsWithLimit($this->modelClass, $this->getPagination()->getLimit(),$offset,$this->getCriteria());
}
}
- A model class with attached behavior:
class CCustomFieldActiveRecord extends CActiveRecord {
public function behaviors() {
return array(
'CustomFields' => array(
'class'=>'application.components.behaviors.MyBehavior',
),
);
}
....
}
- The behavior class:
class MyBehavior extends CBehavior {
private function getCompleteEntityRowsForEntity($entityClassName, ...){
[b]$entityTableName = CActiveRecord::model($entityClassName)->getTableSchema();[/b]
}
}
- Controller class:
class MyController extends EntityController{
public function actionAdmin($mParams = ''){
$this->EntityName = ModelName; // CCustomFieldActiveRecord
$dataProvider = new MyClass($this->EntityName, array(
'pagination' => array(
'pageSize' => $this->PageSize,
),
'criteria' => array(
'with' => array('manufacturer', 'region'),
),
));
.....
}
}
With Yii 1.1.2 works fine in CGridView, when update to Yii 1.1.3,
i) If let like it is the bolded line throws:
Fatal error: Call to a member function getColumnNames() on a non-object in …
ii) If in controller instead of my entity name I send the model object:
$dataProvider = new MyClass(CActiveRecord::model($this->EntityName), array(
'pagination' => array(
'pageSize' => $this->PageSize,
),
'criteria' => array(
'with' => array('manufacturer', 'region'),
),
));
and change rest of classes accordingly, CGridview doesn’t work anymore.
Can anyone help please ?