Yii Framework Forum: CHtml::activeDropDownList - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CHtml::activeDropDownList Rate Topic: -----

#1 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 17 May 2010 - 04:22 AM

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????
0

#2 User is offline   Key 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 07-May 10

Posted 17 May 2010 - 04:37 AM

View Postkitty10, on 17 May 2010 - 04:22 AM, said:

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
0

#3 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 17 May 2010 - 04:42 AM

View PostKey, on 17 May 2010 - 04:37 AM, said:

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 ?
0

#4 User is offline   Key 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 07-May 10

Posted 17 May 2010 - 04:58 AM

View Postkitty10, on 17 May 2010 - 04:42 AM, said:

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'));?>

0

#5 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 17 May 2010 - 05:08 AM

View PostKey, on 17 May 2010 - 04:58 AM, said:

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 :-)
thank you very much
In italian..GRAZIEEEEEEE...:-)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users