attributeLabels charset ???

i have same model SeachAd with CListView atributeLabes not encoded utf , the problem is in sitecontroller i have




actions()

{

'items'=>'application.controller.ItemController'

}



and when i call in layout CMENU




array('label'=>'Apartments', 'url'=>array('items/apartments'),'linkOptions'=>array('class'=>'midle')



i click the Apartments link render ItemController which have apartments action




public function actionApartments(){

	

$dataProvider=new CActiveDataProvider('SeachAd',array( 'criteria'=>array(

		 		'with'=>'AddsOptions.Pictures',

                                'condition'=>'kat_id=1',       

                        ),        ));

	

$this->render('apartments',array('data'=>$dataProvider));

}




thats work to,

then view renders




$this->widget('zii.widgets.CListView', array(

    'dataProvider'=>$data,

    'itemView'=>'items', 

    //'viewData'=>$kats,


     'sortableAttributes'=>array(

                                'name',

                                'tribalstate',

                                'location',

                                'zip',

                        ),


));






in model SeachAd atribte labels have special characters , š ,ž ,




public function attributeLabels(){

              return array(

'name' =>'Naslov',

              	'tribalstate' =>'Odaberite županiju',

              	'location'=>'Odaberite mjesto',

              	'zip'=>'Poštanski Broj',

               

              	);


           }



te widget view order by have Odaberite �upaniju ,

encoding bug

Yep its bug,

ClistView calls CSort function resolveLabel()




public function resolveLabel($attribute)

{

    $definition=$this->resolveAttribute($attribute);

    if(is_array($definition))

    {

        if(isset($definition['label']))

            return $definition['label'];

    }

    else if(is_string($definition))

        $attribute=$definition;

    if($this->modelClass!==null)

        return CActiveRecord::model($this->modelClass)->getAttributeLabel($attribute);

    else

        return $attribute;

}




wich calls

getAttributeLabel(), and returns $labels[$attribute]; i try to encode it returning string charset wich is not utf8 nothing hapend, nothing happend when i try encode and decode with htmlentities ( );

Solution Found, in sortableAttributes set labels directly,




'sortableAttributes'=>array(

'naslov'=>'Naslov',

'zupanija'=>'Županija',

'mjesto'=>'Odaberite mjesto',

'pobroj'=>'Poštanski broj',

      ),



If you use this solution below will be bagged(If your language has it) special characters,




'sortableAttributes'=>array(

'naslov',

'zupanija',

'mjesto',

'pobroj',

      ),



this is not good described on yii class reference

sortableAttributes-detail

CListView




 foreach($this->sortableAttributes as $name=>$label)

{

echo "<li>";

if(is_integer($name))

echo $sort->link($label);

else

echo $sort->link($name,$label);

echo "</li>\n";

}




I think that the problem is that the model is not encoded in utf8.

Change the encode of the model to utf-8 without BOM and all will be fine.

Thanks, zaccaria model was windows-1521, not utf8, works now on both way

Yeah!!

To solve problem with encoding was the job of the first days of work in russia… what a bad weeks I had!