Change item in CActiveDataProvider

Hey there :)

I am currently using the CActiveDataProvider to pass data to my CListView.

One database item is a serialized array, from which I only need the first element. I could put this logic into the (partial) view, but I would rather do it in the Controller, where I create the DataProvider.

Unfortunately I can’t find any “hook” to access only this one item from my DataProvider to modify it.

Can anyone point me in the right direction?

$dataProvider = new CActiveDataProvider('Member');

// Access $dataProvider->myitem and modify it

$this->render('index', array(

    'dataProvider' => $dataProvider,


Best regards


what about CActiveRecord::afterFind()?

Thanks mbi. I need to put the afterFind() into the model, where it is called every time the model is instantiated, right?

Do you know a solution where I can do the logic in the controller? Because I need the model as it is (with the serialized array) for other controllers.

maybe in your model something like that:

private $_firstElement;

public function afterFind()


    $this->_firstElement = $this->getFirstElementFromSerializedArray();


public function getFirstElement()


    return $this->_firstElement;


then in your CGridView

 'value' => '$data->firstElement'

I haven’t thought of that. Massive thanks :)