22.07.2013 Views

download - Index of

download - Index of

download - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Gambar 30. Tampilan Suatu Kategori Thread<br />

Dengan cara seperti itu, user tidak akan menyadari kalau aplikasi sudah<br />

meminta dirinya menginput “kategori” pada thread tersebut dikarenakan sistem<br />

akan menangkap sendiri thread tempat user ingin menambahkan thread baru. Lalu<br />

bagaimana dengan code nya?? Okeh, mari kita bahas..<br />

1. Berikan Parameter Kategori pada actionCreate yang terdapat pada<br />

ThreadController.php<br />

public function actionCreate($id)<br />

{<br />

$model=new Thread;<br />

needed<br />

// Uncomment the following line if AJAX validation is<br />

// $this->performAjaxValidation($model);<br />

if(isset($_POST['Thread']))<br />

{<br />

$model->attributes=$_POST['Thread'];<br />

$model->kategori_id=$id;<br />

$model->user_id=Yii::app()->user->id;<br />

if($model->save())<br />

$this->redirect(array('view','id'=>$model->id));<br />

}<br />

$this->render('create',array(<br />

Page 96

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!