How To Make A Simple Condition Without Relation Database In Yii?

Hello, I am new user Yii.

As always if we want to create the simple conditions of use if in the introduction of the value.

This code below I put in my model.

public function statusCabang($i)



                return "Perhitungan Lembur Staff: Gaji + Tunjangan";

            else if($i==2)

                return "Perhitungan Lembur Non Staff: Gaji + Tunjangan";


                return " ";


This code below I put in my admin view files.


                            'header' => 'Pilihan-pilihan',




1.How to use my function with value like 1, 2 ?

2.whether playing in these conditions should be in GridView? On List View?

try to not use quotes in your CDetailView value, moreover, the use of "$model" should be more appropriate in CDetailView than $data.

However, I use different thing to manage custom expression in value for CDetailView.

I change the line 212 (in 1.1.14) in framework/zii/widgets/CDetailView.php by :


				$value=is_callable($attribute['value']) ? call_user_func($attribute['value'],$this->data) : $attribute['value'];

then in CDetailView, I can use function such as :

'value'=>function($data) {return $data->mySuperFunction();}

But I don’t think this is anymore needed since 1.1.13 or 1.1.14 because just ‘value’=>$model->mySuperFunction(); seems to work