I have user model with first_name and last_name . It will show as full name (first_name+last_name). Now i want to search in Cgridview.
in search
class User extends CActiveRecord { public $fullName;
in search
$criteria->addSearchCondition('concat(first_name, " ", last_name)', $this->fullName);
in rules()
array('..., fullName', 'safe', 'on' => 'search'),
in model created a function
public function getFullName() { return $this->first_name . ' ' . $this->last_name; }
And last I've put it in my view:
<?php $this->widget('zii.widgets.grid.CGridView', array( ....... 'columns' => array( array( 'name' => 'full_name', 'value' => '$data->getFullName()', ), ...