CHtml::activeDropDownList

This is my code




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



The problem is that the data that appears in the drop there aren’t a relation.

in fact I not only view the data on which anagra_anagra_id = anagra_id but all data of the tabel…

can you help me???

Can i put a clause where in the activeDropDownList????

Yes of corse you can put an clause!!

The clause is not in dropdownlist, but in the CActiveRecord->find();

You can pass a CDbCriteria, or you can pass directly a string that will be added to the where condition.

Read about CDbCriteria or CActiveRecord->find().

For example you can do like




<?php echo CHtml::activeDropDownList(

  $model,

   'ANAGRA_ANAGRA_ID',

   CHtml::listData(

      anagrafe::model()->findAll(

         array(

            'order'=>'COGNOME'

            'condition'=>'anagra_anagra_id = anagra_id'

              )

           ),

     'ANAGRA_ID',

     'CognomeNome'

   )));?>



Finally you start to understand how is all working…

Thank you very much…:)…is too long the street!!!