I'm new on Yii, I have Try Crud and succes. now try to create validation but Still error.
here my script Model:Buku.php
public function rules()
{
return array(
array('judul, penulis'),
array('judul', 'length','max'=>50),
array('penulis', 'length', 'max'=>50),
array('judul,penulis', 'on'=>'search'),
);
}
Controller: BukuController.php
public function actionCreate()
{
$model = new Buku;
if(isset($_POST['Buku']))
{
$model->judul =$_POST['Buku']['judul'];
$model->penulis =$_POST['Buku']['penulis'];
$model->save();
/*if($model->save())
{
Yii::app()->user->setFlash('Succes', "Data berhasil Disimpan");
$this->redirect(array('index'));
}*///end of
}//end if isset
$this->render('create',array('model'=>$model));
}//end of class
View: create.php
<div class="form">
<h2>Add Data</h2>
<?php echo CHtml::beginForm(array('buku/create'));?>
<?php
echo CHtml::errorSummary($model);
?>
<div class="row">
<?php echo CHtml::activeLabel($model,'judul');?>
<?php echo CHtml::activeTextField($model,'judul','');?>
<?php echo CHtml::errorSummary($model,'judul');?>
</div>
<div class="row">
<?php echo CHtml::activeLabel($model,'penulis');?>
<?php echo CHtml::activeTextField($model,'penulis','');?>
<?php echo CHtml::errorSummary($model,'penulis');?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit');?>
<?php echo CHtml::endForm();?>
</div>
</div>
the Error MEssage is
Buku has an invalid validation rule. The rule must specify attributes to be validated and the validator name
Anyone can Help This? Im very appreciated Your answer. Thanks