looks like $data in this code is actually replaced by $model->search() than, indeed, returns:
return new CActiveDataProvider('posts', array(
'criteria'=>$criteria,
));
so i tried
<?php
var_dump($model->search()->data);
?>
and it is actually populated with data in my columns, but can’t find a way to access it:
$model->search()->data->id_post_author
is null.
Actually, i would like to do something even more complex: i’d like to link to the user page displaying user’s name, so i should also load the user model… is it probably too much?
I’m having similar issues. I’m using the /views/song/admin.php (song is the name of my view) and using the created grid view. I wanted to insert a hyper link in the cell:
However I have attributes that I’ve added to the model that I want to sort. The sort only allows for actual table columns but I have attributes that are ADDED to the model. Is there a way to sort by those attribute values?
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);
$criteria->compare('name',$this->name,true);
$criteria->compare('p_id',$this->p_id);
$criteria->compare('created',$this->created,true);
$criteria->compare('updated',$this->updated,true);
$criteria->compare('company_id',$this->company_id);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
This is Controller
public function actionDepartmentlist()
{
$model=new Department('search');
$model->unsetAttributes(); // clear any default values
$model->p_id = 0;
// $dataProvider->getData() will return a list of Post objects
// $dataProvider=new CActiveDataProvider('Department');
$this->render('list_department',array(
'model'=>$model,
));
}