listdata concatenate to rows


I’m getting a findAll from DB, in my table I have id, firstname, lastname rows

then putting it into a listData

but I need to concatenate firstname and lastname

is this possible with listData ?

Thanks for your lights


create a method getFullname() in your model, then add the property ‘fullname’ as the textField-param

Thanks for your quick reply

here’s what I did , but it no good

in the model

public function getFullName() {

        return $this->firstname.' '.$this->lastname;


and in the controller

$users = CHtml::listData( Profile::model()->active()->findAll(), 'user_id', Profile::model()->getFullName() );

Property "Profile. " is not defined. :(

Must be:

CHtml::listData(Profile::model()->active()->findAll(), 'user_id', 'fullName');

thanks I added this way

but still get this error

Using $this when not in object context in \user\models\Profile.php on line 191

sorry for the newbiness

actually This could be due to the way the USER Module is set up ?

Well, this problem is actually not topic related :) Still, you can show all related files contents (model, controller, view) so that we can point out a mistake.

:) Thanks

in my Profile Model

is mapped to a table called tbl_profiles with user_id,firstname,lastname

 public static function getFullname() {

        return $this->firstname.' '.$this->lastname;


in my Controller I have this

$users = CHtml::listData( Profile::model()->active()->findAll(), 'user_id', 'fullname' );

This is simply rendered into a dropdown

but I get before getting there

Using $this when not in object context in X:\X_Dev\perfony\perfony\iperfony\protected\modules\user\models\Profile.php on line 191

public static function getFullname() {

  return $this->firstname.' '.$this->lastname;


This should not be a static method.

Thanks Dito that was it!!