but problem is when I update date, default selected value not working for city… , for create it working fine.
This is my view code of state and city dropdown
<div class="row">
<?php echo $form->labelEx($model,'state'); ?>
<?php echo $form->dropDownList($model,'state',CHtml::listData(State::model()->findAll(), 'sid', 'sname'),
array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('user/dynamicCities'), //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#city', //selector to update
array('class'=>'ajaxlink'),
//'data'=>'js:javascript statement'
//leave out the data key to pass all form values through
))); ?>
<?php echo $form->error($model,'state'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'city'); ?>
<?php echo CHtml::dropDownList('city','', array($model->city)); ?>
<?php echo $form->error($model,'city'); ?>
</div>
This is My controller code,
public function actionDynamicCities(){
$data=City::model()->findAll('sid=:sid',
array(':sid'=>$_POST['User']['state']));
$data=CHtml::listData($data,'cname','cname');
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
}
…
and do anyone know how to put loading image with dropdown change, ( loading circle image )
I face dthe problem with country,state,city dropdown .I applied ajax with the country dropdown but while applying on the state dropdown it doesn’t work?