CHtml::activeDropDownList

I have a problem with activeDropDownList.

My code is:




<?php echo CHtml::activeDropDownList($model,'STUDENTE_MATRICOLA',CHtml::listData(anagrafe::model()->findAll(array('order'=>'COGNOME')),'ANAGRA_ID','COGNOME'));?>



But I would add a second parameter with COGNOME also NOME in the view of the attributes in the activeDropDownList.

But if appending the attribute NAME in the listData it’s interpreted as a sttring groupField

How can i resolve this problem????

If I understood what you want to achieve, you can define a function (in the ‘anagrafe’ model) such as:




public function getCognomeNome()

{

   return ($this->COGNOME.' '.$this->NOME);

}	



Then you can use ‘cognomeNome’ as the field to show in the dropDownList

Ok…and after i define this function?

How can i call in my dropdownlist ?

You can use ‘cognomeNome’ as a normal field, so, using your code from the first post:




<?php echo CHtml::activeDropDownList($model,'STUDENTE_MATRICOLA',CHtml::listData(anagrafe::model()->findAll(array('order'=>'COGNOME')),'ANAGRA_ID','cognomeNome'));?>



worksssssss :slight_smile:

thank you very much

In italian…GRAZIEEEEEEE…:slight_smile: