Hi Everyone!
Excuseme for my bad english…
I have two dropdownlist, one dependent from other (i read tutorial from the wiki)
The first represent the code of state and the second represent the city of the specific state…but show only one city (the last of the table).
The two table are:
comuni(id ,codice_provincia,codice,nome)
province(id,codice_regione,codice,nome,sigla)
the part of interest of view is:
<div class="row">
<?php echo $form->labelEx($model,'provincia'); ?>
<?php echo $form->dropDownList($model,'provincia', $città_data,array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('contatti/dynamiccities'),
'update'=>'#'.CHtml::activeId($model,'citta')
)));
?>
<?php echo $form->error($model,'provincia'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'citta'); ?>
<?php echo $form->dropDownList($model,'citta', array());?>
<?php echo $form->error($model,'citta'); ?>
</div>
the part of interest of controller is:
public function actionDynamiccities()
{
$data=Comuni::model()->findAll('codice_provincia=:codice_provincia',array(':codice_provincia'=>1));
$data=CHtml::listData($data,'codice_provincia','nome');
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
}
the value 1 is there to lead the search without "problem"
The function have the authorization in the controller.
So…where is the problem?Why show only one record?
thanks in advance!!
P.s. the DB is correct and populated.