I manage to show Client Firstname and LastName Within Ticket admin view, instead ClientId. But I don´t know how to filter by Cliente Firstname and Client Lastname
you need to create safe variables in your tickets class and then tickets based over these… Also you can need change
search function and add in criteria togather and with(client) fields
Please also note that as your clientId is a single field, you can only filter based on one field i.e. first name or second
you can also achieve filtration based over first name and last name by first finding out all clients with first name or last name and then placing the data in criteria with In method of SQL i.e. where cleintID In()
1.First create 2 virtual properties in Ticket Model.
2.Make them safe on search.
3.Modify the search method
class Ticket extends CActiveRecord
{
public $filter1;
public $filter2;
//Make them safe on search.
public function rules()
{
...
array( 'idTicket ,fiter1,filter2,clientTicket', 'safe', 'on'=>'search' ),
);
}
public function search()
{
$criteria=new CDbCriteria;
$criteria->with=array('ticketClientRelation');
$criteria->together=true;
..............................................
$criteria->compare('ticketClientRelation.firstname',$this->filt1,true);
$criteria->compare('ticketClientRelation.lastname',$this->filt2,true);
....................................................
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}