Property Not Defined

Hello guys, i know this question has been asked at least a thousand times. I can’t however find my mistake, so i was wondering if you guys could help me.

I get this error, when posting a form:


Property "SysReq.class" is not defined.


147      * PHP setter magic method.

148      * This method is overridden so that AR attributes can be accessed like properties.

149      * @param string $name property name

150      * @param mixed $value property value

151      */

152     public function __set($name,$value)

153     {

154         if($this->setAttribute($name,$value)===false)

155         {

156             if(isset($this->getMetaData()->relations[$name]))

157                 $this->_related[$name]=$value;

158             else

159                 parent::__set($name,$value);

160         }

161     }


163     /**

164      * Checks if a property value is null.

165      * This method overrides the parent implementation by checking

166      * if the named attribute is null or not.

167      * @param string $name the property name or the event name

168      * @return boolean whether the property value is null

169      */

170     public function __isset($name)

171     {

Stack Trace




–  /Applications/XAMPP/xamppfiles/htdocs/Sitename/protected/views/game/_form.php(16): CActiveForm->errorSummary(Game, Genre, Platform, SysReq)

11     'enableAjaxValidation'=>false,

12 )); ?>


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


16     <?php echo $form->errorSummary($model,$genre,$platform,$sysReq); ?>


18     <div class="row">

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

20         <?php echo $form->textField($model,'name',array('size'=>45,'maxlength'=>45)); ?>

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




–  /Applications/XAMPP/xamppfiles/htdocs/sitename/protected/views/game/create.php(18): CController->renderPartial("_form", array("model" => Game, "genre" => Genre, "platform" => Platform, "sysReq" => SysReq))

13 );

14 ?>


16 <h1>Create Game</h1>


18 <?php echo $this->renderPartial('_form', array('model'=>$model, 'genre'=>$genre, 'platform'=>$platform, 'sysReq'=>$sysReq)); ?>




–  /Applications/XAMPP/xamppfiles/htdocs/sitename/protected/controllers/GameController.php(89): CController->render("create", array("model" => Game, "genre" => Genre, "platform" => Platform, "sysReq" => SysReq))

84         $this->render('create',array(

85             'model'=>$model,

86             'genre'=>$genre,

87             'platform'=>$platform,

88             'sysReq'=>$sysReq,

89         ));

90     }


92     /**

93      * Updates a particular model.

94      * If update is successful, the browser will be redirected to the 'view' page.

Can you guys give me a hint on what’s wrong?

It’s not easy to help you this way on the forum because we used to see the code of your model, controller and even of the form if possible

Sorry, i should have figured that :)



public function actionCreate()


		$model=new Game;

		$genre=new Genre;

		$platform=new Platform;

		$sysReq=new SysReq;

		// Uncomment the following line if AJAX validation is needed

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

		if(isset($_POST['Game'], $_POST['Genre'], $_POST['Platform'], $_POST['SysReq']))







			if($model->save() && $genre->save() && $platform->save() && $sysReq->save())












<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($model,$genre,$platform,$sysReq); ?>

	<div class="row">

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

		<?php echo $form->textField($model,'name',array('size'=>45,'maxlength'=>45)); ?>

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




	<div class="row">

		<?php echo $form->labelEx($genre,'game_id'); ?>

		<?php echo $form->textField($genre,'game_id'); ?>

		<?php echo $form->error($genre,'game_id'); ?>



	<div class="row">

		<?php echo $form->labelEx($genre,'action'); ?>

		<?php echo $form->checkbox($genre,'action'); ?>

		<?php echo $form->error($genre,'action'); ?>





	<div class="row">

		<?php echo $form->labelEx($platform,'game_id'); ?>

		<?php echo $form->textField($platform,'game_id'); ?>

		<?php echo $form->error($platform,'game_id'); ?>



        <div class="row">

		<?php echo $form->labelEx($sysReq,'os'); ?>

		<?php echo $form->textField($sysReq,'os',array('size'=>60,'maxlength'=>64)); ?>

		<?php echo $form->error($sysReq,'os'); ?>



      	<div class="row buttons">

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


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

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

I’m not sure what model you have to look at, since i got 4 different models pinned to this form.

Please let me know if you should have to look at more in order to help me.

Thank you

Accordingly to your exception stack trace, I see that the Yii ActiveRecord component can’t find the class SysReq.

Do you have any field in your model named SysReq?

okay, so i went through this and checked just about anything i could. What i found out was that i couldn’t have anything else than the $model in my errorsummary. It now works, but i only get errors from my game attributes if i fail to submit anything in an attribute that is required. Do you guys have a fix for that, or is it just something i have to deal with?


I put it all in an array, and it works, but not for more than one table at a time.

<?php echo $form->errorSummary(array($model,$genre,$platform,$sysReq)); ?>

This means that if i try to submit the form without anything, i get errors from the Game-attributes. If i fill them in and leave the other attributes blank, and then submit, i will get errors from the Genre-attributes and so on. Is it possible to let yii show all the errors at the same time?

Maybe this?

<?php echo $form->errorSummary(array($model,$genre,$platform,$sysReq)); ?>

ahh, sorry, i forgot to actually put the code i posted in here in an array :) the code i use in my application is

<?php echo $form->errorSummary(array($model,$genre,$platform,$sysReq)); ?>

i’m going to update the last post i made to this.

bottom line is that I still got the problem

I see.

The problem is in the controller logic.

In the code above, the Genre model won’t be validated if the saving of the Game model has failed. That’s why you get only the errors of one model.

And, you should avoid a situation where $model is saved and $genre, $platform and $sysReq are not.

$valid = $model->validate();

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

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

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

if ($valid)







Ahh thank you. It works now :)