How To Display Name Instead Of Id In Cdetailview

hello everyone…

i am trying to print Location name instead of id in my CDetailView but it’s printing $data->getLocatinName() same thing. i tried this code with CGridView there it’s working fine but here its printing something else.

My CDetail view Code…

<?php $this->widget(‘zii.widgets.CDetailView’, array(

'data'=&gt;&#036;model,


'attributes'=&gt;array(


	....


	array('name'=&gt;'CurrentLocation','value'=&gt;'&#036;data-&gt;getLocationName()'),


            )))

in my model i am calling method getLocationName() code is…

public function getLocationName()

    {


        &#036;query= Locations::model()-&gt;find(&quot;LocationId=&#036;this-&gt;CurrentLocation&quot;);


        &#036;lname=&#036;query['LocationName'];


        return &#036;lname;


    }

Please Suggest how to print name? :unsure:

Hi,

try this…

for example…


'value'=>'Users::model()->Showusernamedd()'


public function Showusernamedd()

    {

        $user_details = User::model()->findAll();

        $dd_data = array();

        if(isset($user_details) && !empty($user_details))

        {

            foreach($user_details AS $user)

            {

                $dd_data[$user->id] = $user->firstname.' '.$user->lastname.' ('.$user->username.') - '.$user->user_type;                    

            }

        }        

        return $dd_data;

    }

Thnaks bro… :D