Hi,
I’m only new to ajax and yii. I’ve been having some problems with dependent drop downs. I’ve followed the the cookbook (cookbook 24) with no luck : (
So here is what I’ve done create a Test table with a country and city column in it. Generated the model/crud using yiic.
Then i edit the _form.php as follows
<div class="row">
<?php echo $form->labelEx($model,'Country'); ?>
<?php echo $form->dropDownList($model,'Country',array(1=>'USA',2=>'Australia',3=>'Thailand'), array('ajax'=>array('type'=>'POST','success'=>'alert("Hi")', 'url'=>'test/dynamiccities','update'=>'#City'))); ?>
<?php echo $form->error($model,'Country'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'City'); ?>
<?php echo $form->dropDownList($model,'City',array()); ?>
<?php echo $form->error($model,'City'); ?>
</div>
I added the success alert to see if its running it seems to but…
Added the following code code to the TestController.php
public function actionDynamiccities() {
echo CHtml::tag('option', array('value'=>'0'), CHtml::encode('Test'), true);
}
And added the function to the security
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view','Dynamiccities'),
'users'=>array('*'),
I get no update on the second drop down.
Still can working out whats wrong. Any help would be greatly appreciated
Thanks in advance
Iain
Edit:
Fixed typo in controller name