Yii Framework Forum: Loading A Yii Widget Form Returning Error - Yii Framework Forum

Jump to content

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

Loading A Yii Widget Form Returning Error Rate Topic: -----

#1 User is offline   marjss 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 16-January 13

Posted 02 April 2013 - 02:15 AM

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>


Have the standard 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". 

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