I want to excute the code that make dependent dropdownlist .I took it from this url
http://www.yiiframework.com/wiki/24/creating-a-dependent-dropdown#hh0
but it’s not excuted for second dropdown, only the first dropdown has been filled. what is problem?.
when I made firebug this error appear You don’t have permission to access /omcproject/protected/controllers/FullTableController/dynamiccities on this server.
I put this in view:
echo CHtml::dropDownList('country_id','', array(1=>'USA',2=>'France',3=>'Japan'),
array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('../protected/controllers/FullTableController/dynamiccities'), //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#city_id', //selector to update
//'data'=>'js:javascript statement'
//leave out the data key to pass all form values through
)));
//empty since it will be filled by the other dropdown
echo CHtml::dropDownList('city_id','', array());
//////////////////////////////////////////////////////////////////////////////////////////////////////////
and this in fullTablecontroller:
public function actionDynamiccities()
{
$data=Location::model()->findAll('parent_id=:parent_id',
array(':parent_id'=>(int) $_POST['country_id']));
$data=CHtml::listData($data,'id','name');
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
}
what is parent_id? and I must change it to wich parameter ? is it constant?
///////////////////////////////////////////////////////////////////////////////////////////////////////////
make autentication for function
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update','../protected/controllers/FullTableController/dynamiccities'),
'users'=>array('@'),
),
If there is a better code please show me.