Trouble with dependant dropdown tutorial

Howdy,

Using 1.1.1, and just went through the dependant dropdown tutorial in the cookbook here.

The tutorial uses CHtml::dropDownList whilst my views use CHtml::activeDropDownList (generated by default crud), so I assume this is why I can’t get it to work. I can’t find what would cause it to behave differently though.

Here is my dropdown (that should cause the ajax routine to update it):


echo CHtml::activeDropDownList($model, 'lang', CHtml::listData(Language::model()->findAll(), 'id', 'lang' ), 

				array(

				'prompt'=>'Select Language...',

				'ajax' => array(

				'type'=>'POST',

				'url'=>'dynamicroots',

				'update'=>'#Word_root',

				)));

Have also tried generating the url with CController::urlCreate() as suggested in the comments of the tutorial, but to no avail.

And here is my handler in my controller:


public function actionDynamicroots() {

		echo CHtml::tag('option', array('value'=>'0'), CHtml::encode('harf1'), true);

		echo CHtml::tag('option', array('value'=>'1'), CHtml::encode('harf2'), true);

		echo CHtml::tag('option', array('value'=>'2'), CHtml::encode('harf3'), true);

	}

Any help is greatly appreciated.

P.S Not sure if this is relevant, but if I try to browse that url manually it gives a 403:


Error 403

You are not authorized to perform this action.

You’re probably having a problem with the rules in your controller. You created a new action that fills the dropdown list in AJAX, but this action doesn’t allow access to anyone. Make sure the controller for this action contains something like:




public function accessRules()

{

	return array(

		array('allow',  // allow all users to perform some actions

			'actions' => array('index', 'view', 'search', 'dynamicroots'),

			'users' => array('*'),

		),



Indeed, Merci François.

So the dependant dropdown works fine, but now I am trying to do a dependant activeTextField, and am having trouble working out how to update it according to what’s selected in the dropdown.

So the scenario is same as above, a dropdown changing activates an ajax request, which is handled by an action in my controller, but I can’t figure out how to update the activeTextField, since it is an attribute of the html which needs to be changed, not a new tag merely inserted, as with the activeDropDownList.