Yii Framework Forum: [ SOLVED ] Gagal save setelah di tambah drop down list - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[ SOLVED ] Gagal save setelah di tambah drop down list Rate Topic: -----

#1 User is offline   Joko 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 30-January 11
  • Location:Jak-sel, Indonesia

Posted 12 February 2011 - 11:53 PM

saya mengkostomisasi sebuah form hasil operasi CRUD, seperti di bawah ini :

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'hrd-travel-berangkat-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

,,,,,,,,,

	<div class="row">
		<?php echo $form->labelEx($model,'Nama'); ?>
		<?php echo $form->dropDownList($model,'travelberangkat_employees',CHtml::listData(HrdEmployees::model()->findAll(), 'id', 'NIKFull_Name')); ?>
		<?php echo $form->error($model,'id_karyawan'); ?>
	</div>

,,,,,,,,,,

<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
			</div>

<?php $this->endWidget(); ?>

</div><!-- form -->


sebelum menggunakan fasilitas dropdownlist, form ini berjalan normal, tapi setelah saya menggunakan dropdownlist form masih bisa tampil, fungsi dropdownlistnya pun OK, tapi malah ngak bisa menyimpan perubahan (baik update maupun entri baru), tolong agan-agan jelaskan mengapa demikian, thanks sebelumnya.
0

#2 User is offline   saebaryo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 13-October 10
  • Location:jogjakarta - Indonesia

Posted 13 February 2011 - 01:21 AM

cek model nya,
- bagian rules udah sesuai dengan perubahan itu atau belum.

- field nama itu tipe datanya udah sesuai atau belum.

mungkin yang lain bisa menambahkan.
everything must standing on balance
1

#3 User is offline   Joko 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 30-January 11
  • Location:Jak-sel, Indonesia

Posted 13 February 2011 - 07:22 PM

Quote

cek model nya,
- bagian rules udah sesuai dengan perubahan itu atau belum.

- field nama itu tipe datanya udah sesuai atau belum.

mungkin yang lain bisa menambahkan.


terima kasih atas responnya agan saebaryo,
yaa benar sekali kalu dilihat dari rules seperti ini :
public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_karyawan, tgl_berangkat, tgl_rencana_kembali', 'required'),
			array('id_karyawan', 'numerical', 'integerOnly'=>true), 
,,,,,,,,,,



array('id_karyawan', 'numerical', 'integerOnly'=>true), <--- disini lah sebenarnya letak pertanyaan saya, gimana cara supaya input yang saya kirimkan/simpan adalah id_karyawan (integer), sedang yang ingin saya tampilkan di drop down list adalah NIKFull_Name / E001(Budi Raharjo) yang bertype Varchar. maaf pertanyaan terlalu mendasar,,, :D
0

#4 User is offline   ibiz4 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 26-November 10
  • Location:Indonesia

Posted 13 February 2011 - 08:56 PM

coba:
<?php echo $form->dropDownList('travelberangkat_employees[id_karyawan]','1',CHtml::listData(HrdEmployees::model()->findAll(), 'id', 'NIKFull_Name')); ?>


sekalian numpang nitip lapak
http://www.yiiframew...dpost__p__74539
WYSIWYG
(What Yii Serve is What You Get)
0

#5 User is offline   -=YiieRz=- 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 177
  • Joined: 27-October 10
  • Location:Jakarta

Posted 13 February 2011 - 10:07 PM

ibiz4, mantap gan jawabannya. btw pesenan ane catet ya gan (hehehe)
belajar itu modal utama, tanpa percobaan itu tak akan berhasil. berdoa itu membuat kita percaya diri. YiieRz-SdgBlajar
www.yiiframework.com
0

#6 User is offline   Joko 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 30-January 11
  • Location:Jak-sel, Indonesia

Posted 14 February 2011 - 02:47 AM

View Postibiz4, on 13 February 2011 - 08:56 PM, said:

coba:
<?php echo $form->dropDownList('travelberangkat_employees[id_karyawan]','1',CHtml::listData(HrdEmployees::model()->findAll(), 'id', 'NIKFull_Name')); ?>


sekalian numpang nitip lapak
http://www.yiiframew...dpost__p__74539

sudah aku coba codingnya ditambahin ,,,, [id_karyawan]','1' ,,,,,, pesan : error Invalid argument supplied for foreach() , ada cara lain ngak gan,

Notes: id = kunci utama di tabel employees dan id_karyawan = kunci tamu di tabel travel.
0

#7 User is offline   ibiz4 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 26-November 10
  • Location:Indonesia

Posted 14 February 2011 - 04:07 AM

View PostJoko, on 14 February 2011 - 02:47 AM, said:

sudah aku coba codingnya ditambahin ,,,, [id_karyawan]','1' ,,,,,, pesan : error Invalid argument supplied for foreach() , ada cara lain ngak gan,

Notes: id = kunci utama di tabel employees dan id_karyawan = kunci tamu di tabel travel.

itu cuma contoh, intinya ya ane kan cuma meraba2 aja desain database agan kyk bagemana.

$model isinya model apa?
klo modelnya Travel ya tinggal dimasukin
<?php echo CHtml::dropDownList('Travel[id_karyawan]','1',CHtml::listData(HrdEmployees::model()->findAll(), 'id', 'NIKFull_Name')); ?>


itu di atas jadinya id_karyawan mau diisi dengan isi id dari model HrdEmployees, dengan default id yg diselect adalah nomer 1

EDIT
up sorry, agan pake CActiveform ya, itu yg ane tulis utk CHtml.
WYSIWYG
(What Yii Serve is What You Get)
1

#8 User is offline   Joko 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 30-January 11
  • Location:Jak-sel, Indonesia

Posted 15 February 2011 - 10:13 PM

syukur sudah SOLVED dengan coding seperti ini,

<?php echo $form->dropDownList($model,'id_karyawan',CHtml::listData(HrdEmployees::model()->findAll(), 'id', 'NIKFull_Name')); ?>


ternyata dia minta di isi FK (id_karyawan),$form->dropDownList($model,'id_karyawan',CHtml::listData(HrdEmployees::model()->findAll(), 'id', 'NIKFull_Name')); ?>

thanks sangat untuk agan2 diatas.
0

#9 User is offline   ibiz4 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 26-November 10
  • Location:Indonesia

Posted 16 February 2011 - 08:21 PM

di rename judul tritnya tambahin SOLVED
WYSIWYG
(What Yii Serve is What You Get)
0

#10 User is offline   saebaryo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 13-October 10
  • Location:jogjakarta - Indonesia

Posted 17 February 2011 - 02:29 AM

View Postibiz4, on 16 February 2011 - 08:21 PM, said:

di rename judul tritnya tambahin SOLVED


^
^
menciptakan budaya baik di forum.

terus kalo mau berterimakasih atau ngasih cendol, klik tanda plus warna hijau

Attached File  reputation.jpg (4.05K)
Number of downloads: 12

everything must standing on balance
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users