Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Add Attributes After Finall Function In Model

$
0
0
Hi Friends,
I am calling the findall method and i am getting 4 fields.I now want to add one more field named $owned.
SO that means after i get the record form the table, the resultant datarecord should contain the owned field.
Also the $owned field is dynamic based on whether user is the owner of the group. I tried using afterFind. But it is also not working. Surprisingly it is adding attributed owned to the object but not to attributes.

below is the code


/**
*
* The followings are the available columns in table 'group':
* @property integer $id
* @property string $name
* @property string $created_at
* @property string $updated_at
*/

class Group extends CActiveRecord
{
//adding owned property for groups.true if user is owner
public $owned;
protected function afterFind()
{
parent::afterFind();
//if user is owner of group its true
$this->owned = true;
}

Thanks to all
Smith

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>