kitty10
(Martde)
1
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?
Key
(Hammerfox)
2
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
kitty10
(Martde)
3
Ok…and after i define this function?
How can i call in my dropdownlist ?
Key
(Hammerfox)
4
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'));?>