Guys I have finally got dependent drop box to work on my form. However, when I press submit the value does not get inserted in the db table. I understand that the code in the form for the dependent dropbox was changed. however the ‘cityId’ matches that in the model.
<div class="row">
<?php echo $form->labelEx($model,'cityId'); ?>
<?php echo CHtml::dropDownList('cityId','', array()); ?>
<?php echo $form->error($model,'cityId'); ?>
</div>
I am not using echo $form->dropDownList($model,cityId,…);
Is this the problem.
This is the output I get after pressing submit. The dependent dropdown is blank. If I all Null values for cityID in database table, then Null value gets inserted. Here is code from controller function
public function actionCity()
{
$data=City::model()->findAll('stateId=:id',
array(':id'=>(int) $_POST['Ticket']['stateId']));
$data=CHtml::listData($data,'id','name');
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
}
3144