Posted by admin on 29 Mär 2012 in spooXe
I found my solution under the link from Harry
$config = array('keyField' => 'idheatflow');
$dataProvider = new CArrayDataProvider($rawData=$model->heatflows, $config);
I found my solution under the link from Harry
$config = array('keyField' => 'idheatflow');
$dataProvider = new CArrayDataProvider($rawData=$model->heatflows, $config);
for all tables the following:
Path for a giix code in crud generator:
Model Class
application.modules.heatflow.models.Heatflow
Controller ID
heatflow/Heatflow
Meanwhile another error message is coming:
Table 'heatflow' has a composite primary key which is not supported by crud generator.
I have a try to giix Extension. I am lazy and think is better to install extensions for better building the code.
public function validateModel($attribute,$params)
{
if($this->hasErrors('model'))
return;
$class=@Yii::import($this->model,true);
if(!is_string($class) || !$this->classExists($class))
$this->addError('model', "Class '{$this->model}' does not exist or has syntax error.");
else if(!is_subclass_of($class,'CActiveRecord'))
$this->addError('model', "'{$this->model}' must extend from CActiveRecord.");
else
{
$table=CActiveRecord::model($class)->tableSchema;
if($table->primaryKey===null)
$this->addError('model',"Table '{$table->name}' does not have a primary key.");
else if(is_array($table->primaryKey))
$this->addError('model',"Table '{$table->name}' has a composite primary key which is not supported by crud generator.");
else
{
$this->_modelClass=$class;
$this->_table=$table;
}
}
}
Solution will be a workaround to that composite primary key. Using only one primary key. Other keys can not be primary.