Field's value disappears after submit

It shouldn’t be a big thing at all but I really can’t get around it.

I’ve created a CRUD by Gii and I didn’t touch the generated code. The problem is my $model->attributes disappears somewhere and I just can’t figure out where!

The controller action :




public function actionCreate()

	{

		$model=new AttributeType;


		// Uncomment the following line if AJAX validation is needed

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


		if(isset($_POST['AttributeType']))

		{

			$model->attributes=$_POST['AttributeType'];

			print_r($model->attributes);

			if($model->save())

				$this->redirect(array('view','id'=>$model->ID));

		}


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

			'model'=>$model,

		));

}

The model rule :




public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('Title', 'required'),

			array('Title', 'length', 'max'=>100),

			// The following rule is used by search().

			// Please remove those attributes that should not be searched.

			array('ID, Title', 'safe', 'on'=>'search'),

		);

	}



As you can see in figure below, result of


print_r($model->attributes);

indicates that controller receives the value but I dunno what happens after save() that the value becomes empty. Am I missing something?

Have you checked the yii/requirements/ on your web server, I suspect there is something missing.

I don’t think so since the same server configuration is hosting two other Yii applications.

For the records, the problem was that I had a relationship defined with name "attributes" which was causing the problem.


'attribtues' => array(self::HAS_MANY, 'Attribute', 'AttributeType_ID')

changing name of the relationship solved it.