CGridView with mulitple model

I have figured out that this is not the setup it is an issue with a CActiveForm that I have in my view. It is separate from the CGridView but it is still in conflict. I have searched the Forum but haven’t found the exact example that will fix my issue.

Here is my code for my ActiveForm




<div class="form"> 


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

	'id'=>'sessionclass-form',

	'enableAjaxValidation'=>false,

	

));

$model=$sessionclassInstance;

$classConfigModel=$classConfigInstance;

 ?>

	

		

		<?php echo $form->hiddenField($model,'session_id',array('value'=>$currentSessionID)); ?>

		

	

	

	

		<?php echo $form->labelEx($model,'Available Classes for this Session'); ?>

		

		<?php echo $form->dropDownList($model,'class_id',$classDropDown);?>

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

	

		<?php $classConfigsList = $configInstance->findAllByAttributes(array('type'=>'class'));

			  $configItemValue='';

			  

			  if($classConfigsList)

			  {

			  	

			  		foreach($classConfigsList as $classConfigListItem)

			  		{		  		

			  			$labelName = $classConfigListItem->config_name;

					  	echo $form->labelEx($classConfigModel,$labelName );

						echo $form->textfield($classConfigModel,$classConfigListItem->id,array('value'=>$configItemValue,));

						echo $form->error($classConfigModel,'value'); 

			  		}

			  }

		

		?>

	<?php echo '<br />';?>

		<?php echo CHtml::submitButton('Add Class'); ?>

	


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


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



I am not an expert, but I think this might be the problem:

The value provided in CGridView->columns->name must match the name of your variable (SessionClass->class_name), so it should be (i think):




    array('name' => 'class_name',

        'value' => '$data->class->class_name',

        'type' => 'text'),



Additionally, You are using search method of SessionClass model, so this additional field, class_name, should go into SessionClass. I can’t tell from the code if that is set right in your code.

@kellan4459 - this was for your previous post.

@Halfdan

If I comment out all of the form code in my 18 November 2011 - 06:54 PM post the search works again.