I made _form.php entry data file using 3 dependent dropdownlist (id_company, id_ledgers, id_ledgers_detail).
id_company update id_ledgers field and id_ledgers field update id_ledgers_detail field.
Here’s my codes.
My View Code:
<div class="column">
	<?php 
	echo $form->labelEx($model,'id_company');
	echo $form->dropDownList($model,'id_company',
		CHtml::listData(Company::model()->sc_cust()->findAll(),'id','deskripsi')
		,array(
			'empty'=>'---Silahkan pilih---',
			'ajax' => array(
				'type'=>'POST',
				'url'=>CController::createUrl('retur_dtl/pilih_nt'),
				'update'=>'#'.CHtml::activeId($model,'id_ledgers'),
			),
		)
	);
	echo $form->error($model,'id_company'); 
	?>
</div>
<div class="row">
	<?php
	echo $form->labelEx($model,'id_ledgers');
	echo $form->dropDownList($model,'id_ledgers'
		,array(
			'prompt'=>'Pilih Pelanggan Dulu',
			'ajax' => array(
				'type'=>'POST',
				'url'=>CController::createUrl('retur_dtl/pilih_prd'),
				'update'=>'#'.CHtml::activeId($model,'id_ledgers_detail'),
			),
		)
	);
	echo $form->error($model,'id_ledgers'); 
	?>
</div>
<div class="row">
	<?php
	echo $form->labelEx($model,'id_ledgers_detail');
	echo $form->dropDownList($model,'id_ledgers_detail'
		,array(
			'prompt'=>'Pilih Penjualan Dulu',
		)
	);
	echo $form->error($model,'id_ledgers_detail'); 
	?>
</div>
Here’s my controller codes:
/**
 * Dependent dropdown pilih NT
 */
public function actionPilih_nt()
{
	$data=Ledgers::model()->findAllBySql('
	SELECT 
		id, 
		CONCAT("NT",IF(IFNULL(nota_a,"")="", faktur, CONCAT(faktur,".",IFNULL(nota_a,""))),"/",YEAR(tanggal)) AS bukti,  YEAR(tanggal) AS tahun
	FROM kup_ledgers 
	WHERE 
		kup_ledgers.type_ledger=3 AND 
		IFNULL(kup_ledgers.pengurang_bayar,0)<IFNULL(kup_ledgers.total_nota_ppn,0) AND 
		kup_ledgers.company='.$_POST['Retur_dtl']['id_company'].' AND
		IFNULL(kup_ledgers.flagl_bastb,0)=0
	UNION ALL
	SELECT 
		id, 
		CONCAT("BASTB",IF(IFNULL(nota_a,"")="", faktur, CONCAT(faktur,".",IFNULL(nota_a,""))),"/",YEAR(tanggal)) AS bukti,  YEAR(tanggal) AS tahun 
	FROM kup_ledgers 
	WHERE 
		kup_ledgers.type_ledger=3 AND 
		IFNULL(kup_ledgers.pengurang_bayar,0)<IFNULL(kup_ledgers.total_nota_ppn,0) AND 
		kup_ledgers.company='.$_POST['Retur_dtl']['id_company'].' AND
		IFNULL(kup_ledgers.flagl_bastb,0)=1
	ORDER BY tahun, bukti
	');
	$data=CHtml::listData($data,'id','bukti');
	foreach($data as $value=>$nama)
	{
			echo CHtml::tag('option',array('value'=>$value),CHtml::encode($nama),true);
	}
}
/**
 * Dependent dropdown pilih Produk
 */
public function actionPilih_prd()
{
	$data=Ledgers_detail::model()->findAllBySql('
	SELECT 
		id, 
		stock
	FROM kup_ledgers_detail
	WHERE 
		ledger='.$_POST['Retur_dtl']['id_ledgers']
	);
	$data=CHtml::listData($data,'id','stock');
	foreach($data as $value=>$nama)
	{
			echo CHtml::tag('option',array('value'=>$value),CHtml::encode($nama),true);
	}
}
The first dropdownlist (id_company) success update second dropdownlist (id_ledgers) but the second dropdownlist failed to update third dropdownlist (id_ledgers_detail).
Can anyone help me find what’s wrong with my code?