Reputation: 208
I have a one table, the name table is 'siswa', and has primary Key 'nim' and other field 'nama','alamat','tanggal_lahir' and other. I want to fill all fieldtext base dropdownlist in Yii framework. with my code is shown/updated with one textfield only, I want populate all textfield.
Here my view form_ code :
<?php
Yii::app()->clientScript->registerScript("combo-change", "
$(document).ready(function(){
$('#nim').change(function(){
sel = $(this);
console.log(sel.val());
if(sel.val() != '' ){
$('#Siswa_nama').val(sel.val());
$('#Siswa_nama').attr('disabled', 'disabled');
$('#Siswa_alamat').val(sel.val());
$('#Siswa_alamat').attr('disabled', 'disabled');
}
});
});
");
?>
<?php $SiswaArray = CHtml::listData(Siswa::model()->findAll(array(
//'order'=>'nama ASC',
//'group' => 'kelas',
//'distinct' => true
)),'nama','nim');
?>
<?php echo $form->dropDownList($model, 'nim', $SiswaArray, array('class'=>'span3', 'empty' => '-- select NIM --', 'id' => 'nim')); ?>
<div class="row">
<?php echo $form->labelEx($model,'nama');?>
<?php echo $form->textField($model,'nama', array('class'=>'span2', 'id' => 'Siswa_nama', 'placeholder'=>'nama')); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'Alamat');?>
<?php echo $form->textField($model,'alamat', array('class'=>'span3', 'id' => 'Siswa_alamat', 'placeholder'=>'alamat')); ?>
</div>
Even, the output only 'nama' is updated, but alamat or other not updated. like here :
I hope there a answer or solution for this, I confused, spend a week for this. Hope Your Answer.
Thank you,
Upvotes: 0
Views: 593
Reputation: 838
in your controller: SiswaController.php
function actionCreate(){ //if it is create action
//add this code if you have $model= new Siswa;
$model->alamat = $model->alamat;
}
Upvotes: 0