Reputation: 1199
i have a tabs in view by which in one tab i want to show a form through a widget call.
<div class="tabcontent" id="country2">
<div class="No-Time">No Reviews !
<?php $this->widget('Review');?>
</div>
</div>
Created the Review
model for this.Then i create the component
<?php
class Review extends CWidget
{
public $title='Review';
public $visible=true;
public function run()
{
if($this->visible)
{
$this->renderContent();
}
}
protected function renderContent()
{
$merchant_id = Yii::app()->user->id;
$model = new Review;
$this->performAjaxValidation($model);
$valid = $model->validate();
if(isset($_POST['ajax']) && $_POST['ajax']==='review-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
$this->render('Review',array('model'=>$model));
}
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='review-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
?>
This is my Component View file:
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'review-form',
'enableAjaxValidation'=>false,
)); ?>
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textField($model,'name'); ?>
<?php echo $form->error($model,'name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'email'); ?>
<?php echo $form->textField($model,'email'); ?>
<?php echo $form->error($model,'email'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'review'); ?>
<?php echo $form->textField($model,'review'); ?>
<?php echo $form->error($model,'review'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'mobile'); ?>
<?php echo $form->textField($model,'mobile'); ?>
<?php echo $form->error($model,'mobile'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'status'); ?>
<?php echo $form->textField($model,'status'); ?>
<?php echo $form->error($model,'status'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'website'); ?>
<?php echo $form->textField($model,'website'); ?>
<?php echo $form->error($model,'website'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'avtar'); ?>
<?php echo $form->textField($model,'avtar'); ?>
<?php echo $form->error($model,'avtar'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'date'); ?>
<?php echo $form->textField($model,'date'); ?>
<?php echo $form->error($model,'date'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit'); ?>
</div>
<input type="hidden" name="merchant" id="merchant-id" />
<?php $this->endWidget(); ?>
</div>
Having this error return. Dont know why this occured.
Review and its behaviors do not have a method or closure named "isAttributeRequired".
Upvotes: 0
Views: 1159
Reputation: 14860
You need to rename your component to something other than Review
. The error is because the line $model= new Review
creates an instance of the Review component rather than the Review model.
Upvotes: 2