Yii Framework Forum: Tanya Input Tabular - Yii Framework Forum

Jump to content

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

Tanya Input Tabular Rate Topic: -----

#1 User is offline   paxee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 19-June 13

Posted 20 July 2013 - 03:34 AM

slamat siang para masta yii
saya baru nyoba yii nih
jadi saya punya table dosen dengan attribut id,nama dan alamat
dan mau buat update model table biar tidak satu satu updatenya
tapi setiap mau create muncul Call to a member function getValidators() on a non-object

ini code di dosencontroler
public function actionUpdate($id)
{
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

$model=$this->loadModel($id);

if(isset($_POST['Dosen']))
{
$valid=true;
foreach($model as $i=>$dosen)
{
if(isset($_POST['Dosen'][$i]))
$dosen->attributes=$_POST['Dosen'][$i];
$valid=$dosen->validate() && $valid;
}
if($valid) // seluruh item valid
// ...lakukan sesuatu di sini
$this->redirect(array('view','id'=>$model->id));
}


$this->render('update',array(
'model'=>$model,
));
}

ini di _formnya
/div><!-- form -->
<div class="form">
<?php echo CHtml::beginForm(); ?>
<table>
<tr><th>id</th><th>nama</th><th>alamat</th></tr>
<?php foreach($model as $i=>$dosen): ?>
<tr>
<td><?php echo CHtml::activeTextField($dosen,'[$i]id'); ?></td>
<td><?php echo CHtml::activeTextField($dosen,'[$i]nama'); ?></td>
<td><?php echo CHtml::activeTextField($dosen,'[$i]alamat'); ?></td>

</tr>
<?php endforeach; ?>
</table>

<?php echo CHtml::submitButton('Save'); ?>
<?php echo CHtml::endForm(); ?>
</div><!-- form -->

mohon pencerahannya :)
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