Dynamic DropDown in Activeforms

Hi,

I encountered a little problem with dynamic dropdowns




	<div class="row">

		<?php echo $form->labelEx($model,'realm'); ?>

                <?php echo $form->dropDownList($model,'realm', array('prompt'=>'Please select', '0'=>'Mithral', '1'=>'Anvien', '2'=>'Corelan'),

                    array(

                    'ajax' => array(

                    'type'=>'GET', //request type

                    'url'=>CController::createUrl('character/ajaxRace'), //url to call.

                    'update'=>'#'.CHtml::activeId($model,'race'), //selector to update

                    'data'=>array('realm'=>'js:this.value'),

                    ))                        

                ); ?>

		<?php echo $form->error($model,'realm'); ?>

	</div>        

        

	<div class="row">

		<?php echo $form->labelEx($model,'race'); ?>

                <?php echo $form->dropDownList($model, 'race', array('prompt'=>CHtml::encode('Please select'))); ?>

		<?php echo $form->error($model,'race'); ?>

	</div>



Ok, so this is working great for creating a new Entry.

But if you want to update, the ajax request is only invoked when changing the value.

So how do I get him to make that ajax call when loading ?

Greetings

Why would you make an ajax call on loading… you already have his value and the value of the next dropdown…

So on loading you show both values as selected… and only if the first value changes… ajax is fired that will change the second dropdown… if nothing is changed they both have the old values…

Yeah I know … but the problem is, that the values of that depending dropdown are loaded dynamicaly, depending on the first dropdown

But…

As I wrote above… in the actionUpdate() you have the value for the first dropdown… and you can already populate the second one… and as you have the value of the second dropdown… the proper value will be selected…

That’s a good point.

But as I’m working with ActiveForms I don’t see any possibility setting dropdown values from a controlleraction.

Am I missing something ?

Check this similar thread with same question on comment #6 - http://www.yiiframework.com/forum/index.php?/topic/11531-