Yii Part 2 – Look-up values

There is a great post here which describes how to define a Lookup model such that you can embed lookup values with great ease as follows:-

 PHP |  copy code |? 
01
$this->widget('zii.widgets.CDetailView', array(
02
 'data'=>$model,
03
 'attributes'=>array(
04
 'id',
05
 'title',
06
 'content',
07
 'tags',
08
 array(
09
 'name'=>'status',
10
 'value'=&gt;<span style="color: #ff9900;">Lookup::item('PostStatus',$model-&gt;status)</span>
11
 ),
12
 'create_time',
13
 'update_time',
14
 array(
15
 'name'=&gt;'author_id',
16
 'value'=&gt;User::model()-&gt;find(
17
 'id=:author_id',
18
 array(
19
 ':author_id'=&gt;$model-&gt;author_id
20
 )
21
 )-&gt;username,
22
 ),
23
 ),
24
 ));



If you found this article useful » please +1 me on Google.