Multimodel Error In Yii

Before asking a question I want to say that I have asked this question in stackoverflow but not got any good result.I am a newbie to the Yii framework.I want a multimodel form so I just went through this link and made all things like this.I have two table, first is group and another is member.









Now I have made models for both tables and CRUD as well.I made change to GroupController file like this

public function actionCreate()


    $group = new Group;

    $member = new Member;

    if(isset($_POST['Group'],$_POST['Member'])) {

    //Populate input data to $group and $member

      $group->attributes = $_POST['Group'];

      $member->attributes = $_POST['Member'];

    //Validate both $group and $member

      $validate = $group->validate();

      $validate = $member->validate() && $valid;







      'group'=> '$group',

      'member'=> '$member',


    $model=new Group;

    // Uncomment the following line if AJAX validation is needed

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











and after changing the group >> View >> create.php file like this

<?php echo $this->renderPartial('_form', array('group'=>$group, 'member'=>$member)); ?>

The _form file is like this

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(



)); ?>

  <p class="note">Fields with <span class="required">*</span> are required.</p>

  <?php echo $form->errorSummary($group,$member); ?>

  <div class="row">

    <?php echo $form->labelEx($model,'name'); ?>

    <?php echo $form->textField($model,'name'); ?>

    <?php echo $form->error($model,'name'); ?>


  <div class="row">

    <?php echo $form->labelEx($member,'firstname'); ?>

    <?php echo $form->textField($member,'firstname',array('size'=>60,'maxlength'=>128)); ?>

    <?php echo $form->error($member,'firstname'); ?>


  <div class="row buttons">

    <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>


<?php $this->endWidget(); ?>

</div><!-- form -->

but after all I am getting error like this Undefined variable: group . So can some one please tell me how to solve this issue. I have lost one day behind this.So any help and suggestions will be highly appreciable.

Hi NewUser

Try to delete single quotes. Instead of


      'group'=> '$group',

      'member'=> '$member',




      'group'=> $group,

      'member'=> $member,


Ya I tried that but it not worked.

Check a bit your actionCreate… you are rendering the "create" view 2 times !

The first time you sending variables "group" and "memeber", the second time you are sending the variable "model"

so the second time there is no “group” and no “member” variable and that’s where you get the error…