Yii Framework Forum: [Solved] Event select deselect pada CCheckBoxColumn [Part-2] - Yii Framework Forum

Jump to content

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

[Solved] Event select deselect pada CCheckBoxColumn [Part-2] Rate Topic: -----

#1 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 05 May 2011 - 01:27 AM

Haloo master-master Yii...
Aq mo nanya lagi nih. :D

Kemaren kan cara select dan deselect pada CCheckBoxColumn sudah berhasil.
Nah sekarang aq mau masukin nilai ke sebuah field berdasarkan select dan deselect
Misal :
1.ada table Mahasiswa, punya field status.
2.Aq punya tombol untuk eksekusi status.
3.Eksekusi status berdasarkan CheckboxColumn
4.field 'status' akan bernilai 'aktif' klo checkboxColumnnya kondisi diceklis.
field 'status' akan bernilai 'non-aktif' klo checkboxColumnnya kondisi tidak diceklis.

Minta solusinya donk gan. :D
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#2 User is offline   itmagetan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 90
  • Joined: 25-February 11

Posted 05 May 2011 - 02:21 AM

Contoh kalau pakai Model dan CActiveForm:
Di formnya:
	<div class="row">
		<?php echo $form->checkBox($model,'status'); ?>
		<?php echo $form->labelEx($model,'status'); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

Di Controllernya:
		if(isset($_POST['Mahasiswa']))
		{
			$model->attributes=$_POST['Mahasiswa'];
			
			if($_POST['Mahasiswa']['status']==0)
				$model->status='inactive';
			else
				$model->status='active';
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

0

#3 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 05 May 2011 - 02:32 AM

View Postitmagetan, on 05 May 2011 - 02:21 AM, said:

Contoh kalau pakai Model dan CActiveForm:
Di formnya:
	<div class="row">
		<?php echo $form->checkBox($model,'status'); ?>
		<?php echo $form->labelEx($model,'status'); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

Di Controllernya:
		if(isset($_POST['Mahasiswa']))
		{
			$model->attributes=$_POST['Mahasiswa'];


			
			if($_POST['Mahasiswa']['status']==0)
				$model->status='inactive';
			else
				$model->status='active';
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}


klo CActiveForm saya pake ini.
<?php echo $form->checkBox($model,'status',array('value' => 'aktif', 'uncheckValue'=>'non-aktif')); ?>


Tapi untuk CCheckBoxColumn saya rada bingung masukin value-nya ke table.
tolongin donk gan. :(
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#4 User is offline   itmagetan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 90
  • Joined: 25-February 11

Posted 05 May 2011 - 02:52 AM

Pastekan kode2nya disini: controller, model dan viewnya
0

#5 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 05 May 2011 - 03:49 AM

View Postitmagetan, on 05 May 2011 - 02:52 AM, said:

Pastekan kode2nya disini: controller, model dan viewnya


Emang nantinya panjang ya banget gan?. Ampe tiga2nya diminta begitu.
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#6 User is offline   itmagetan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 90
  • Joined: 25-February 11

Posted 05 May 2011 - 05:08 AM

Kalau sepotong-sepotong susah untuk analize-nya
0

#7 User is offline   petra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 20-June 10

Posted 05 May 2011 - 06:33 AM

si CGridViewnya dibungkus sama form (CHtml::beginForm() sama CHtml::endForm()),,

terus sebelum CHtml::endForm() kasih CHtml::ajaxSubmitButton() (misalnya 2 buah,, satu buat "Activate Selected", sama "Deactivate Selected")

liat data apa yang dikirim ke server pas ajaxSubmitButtonnya diklik :P (ngeliatnya pake FireBug),,

itu cluenya :)

http://www.yiiframew...itButton-detail
0

#8 User is offline   itmagetan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 90
  • Joined: 25-February 11

Posted 05 May 2011 - 07:33 AM

View Postpetra, on 05 May 2011 - 06:33 AM, said:

si CGridViewnya dibungkus sama form (CHtml::beginForm() sama CHtml::endForm()),,

terus sebelum CHtml::endForm() kasih CHtml::ajaxSubmitButton() (misalnya 2 buah,, satu buat "Activate Selected", sama "Deactivate Selected")

liat data apa yang dikirim ke server pas ajaxSubmitButtonnya diklik :P (ngeliatnya pake FireBug),,

itu cluenya :)

http://www.yiiframew...itButton-detail


Ini disebut "coding dengan cerdas", jadi tidak sekedar copas references yang belum tentu jalan di project kita, alias perlu penyesuaian..he2..
Manteb bung petra, bagi lagi dong tips2 lainnya. ;D
0

#9 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 23 May 2011 - 03:21 AM

View Postpetra, on 05 May 2011 - 06:33 AM, said:

si CGridViewnya dibungkus sama form (CHtml::beginForm() sama CHtml::endForm()),,

terus sebelum CHtml::endForm() kasih CHtml::ajaxSubmitButton() (misalnya 2 buah,, satu buat "Activate Selected", sama "Deactivate Selected")

liat data apa yang dikirim ke server pas ajaxSubmitButtonnya diklik :P (ngeliatnya pake FireBug),,

itu cluenya :)

http://www.yiiframew...itButton-detail

Ma'af sebelumnya, klo balasnya lama.
makasih ya mas petra atas masukannya...
saya ikuti langkah2 dari mas petra,
Alhamdulillah sudah berhasil...
makasih ya mas.... :D
Alhamdulillah Solved
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#10 User is offline   qikio 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 10-August 12
  • Location:Jakarta

Posted 31 August 2012 - 08:19 PM

View PostO, on 23 May 2011 - 03:21 AM, said:

Alhamdulillah Solved


kebetulan aku juga ada kasus kayak gini,
bisa share code nya ga?
maklum newbie :)
0

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